update libvirt and templ
- doing work around routing to use simpleroute - doing work around logging with simplelog
This commit is contained in:
parent
69bffd0d40
commit
760d7063de
17
go.mod
17
go.mod
@ -3,16 +3,25 @@ module git.staur.ca/stobbsm/clustvirt
|
|||||||
go 1.22.1
|
go 1.22.1
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/a-h/templ v0.2.646
|
git.staur.ca/stobbsm/simplelog v0.0.0-20240407172718-26a74495adc9
|
||||||
github.com/go-chi/chi/v5 v5.0.12
|
git.staur.ca/stobbsm/simpleroute v0.0.0-20240407195233-523f184fd406
|
||||||
|
github.com/a-h/templ v0.2.648
|
||||||
github.com/jaypipes/pcidb v1.0.0
|
github.com/jaypipes/pcidb v1.0.0
|
||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cobra v1.8.0
|
||||||
libvirt.org/go/libvirt v1.10001.0
|
libvirt.org/go/libvirt v1.10002.0
|
||||||
libvirt.org/go/libvirtxml v1.10001.0
|
libvirt.org/go/libvirtxml v1.10001.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/go-chi/chi/v5 v5.0.12 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/mitchellh/go-homedir v1.0.0 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
github.com/rs/zerolog v1.32.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
golang.org/x/sys v0.19.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace git.staur.ca/stobbsm/simpleroute => ../simpleroute
|
||||||
|
32
go.sum
32
go.sum
@ -1,24 +1,44 @@
|
|||||||
github.com/a-h/templ v0.2.646 h1:F4+tGmPavtPMdWF3ofCDkPx/31qtInztsmUdzu6EzVU=
|
git.staur.ca/stobbsm/simplelog v0.0.0-20240407172718-26a74495adc9 h1:A3XQw1dxgNqAHWUzzz2zdAV8bWHIEvxRgF+JYo4/elc=
|
||||||
github.com/a-h/templ v0.2.646/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8=
|
git.staur.ca/stobbsm/simplelog v0.0.0-20240407172718-26a74495adc9/go.mod h1:ruZaa6TgS/lJ4lC78nXHm4sb+zftJ0IwsEN7mvaksc8=
|
||||||
|
github.com/a-h/templ v0.2.648 h1:A1ggHGIE7AONOHrFaDTM8SrqgqHL6fWgWCijQ21Zy9I=
|
||||||
|
github.com/a-h/templ v0.2.648/go.mod h1:SA7mtYwVEajbIXFRh3vKdYm/4FYyLQAtPH1+KxzGPA8=
|
||||||
|
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s=
|
||||||
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
|
||||||
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
github.com/jaypipes/pcidb v1.0.0 h1:vtZIfkiCUE42oYbJS0TAq9XSfSmcsgo9IdxSm9qzYU8=
|
github.com/jaypipes/pcidb v1.0.0 h1:vtZIfkiCUE42oYbJS0TAq9XSfSmcsgo9IdxSm9qzYU8=
|
||||||
github.com/jaypipes/pcidb v1.0.0/go.mod h1:TnYUvqhPBzCKnH34KrIX22kAeEbDCSRJ9cqLRCuNDfk=
|
github.com/jaypipes/pcidb v1.0.0/go.mod h1:TnYUvqhPBzCKnH34KrIX22kAeEbDCSRJ9cqLRCuNDfk=
|
||||||
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
|
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
|
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||||
|
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
||||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
|
||||||
|
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
libvirt.org/go/libvirt v1.10001.0 h1:lEVDNE7xfzmZXiDEGIS8NvJSuaz11OjRXw+ufbQEtPY=
|
libvirt.org/go/libvirt v1.10002.0 h1:ZFQsv1G8HE8SYhLBqaOuxze6+f00x96khLwn54aWJnI=
|
||||||
libvirt.org/go/libvirt v1.10001.0/go.mod h1:1WiFE8EjZfq+FCVog+rvr1yatKbKZ9FaFMZgEqxEJqQ=
|
libvirt.org/go/libvirt v1.10002.0/go.mod h1:1WiFE8EjZfq+FCVog+rvr1yatKbKZ9FaFMZgEqxEJqQ=
|
||||||
libvirt.org/go/libvirtxml v1.10001.0 h1:r9WBs24r3mxIG3/hAMRRwDMy4ZaPHmhHjw72o/ceXic=
|
libvirt.org/go/libvirtxml v1.10001.0 h1:r9WBs24r3mxIG3/hAMRRwDMy4ZaPHmhHjw72o/ceXic=
|
||||||
libvirt.org/go/libvirtxml v1.10001.0/go.mod h1:7Oq2BLDstLr/XtoQD8Fr3mfDNrzlI3utYKySXF2xkng=
|
libvirt.org/go/libvirtxml v1.10001.0/go.mod h1:7Oq2BLDstLr/XtoQD8Fr3mfDNrzlI3utYKySXF2xkng=
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
package host
|
|
||||||
|
|
||||||
import "github.com/go-chi/chi/v5"
|
|
||||||
|
|
||||||
func (h *Host) HTMXRenderHandler(router *chi.Router) {
|
|
||||||
}
|
|
@ -10,70 +10,54 @@ import (
|
|||||||
router "git.staur.ca/stobbsm/simpleroute"
|
router "git.staur.ca/stobbsm/simpleroute"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Htmx = router.Routes{
|
func Routes(c *cluster.Cluster) *router.Router {
|
||||||
{
|
r := router.New()
|
||||||
Method: http.MethodGet,
|
r.Get("/cluster", func(w http.ResponseWriter, r *http.Request) {
|
||||||
Path: "/cluster",
|
if err := view.ClusterInfo(c).Render(context.Background(), w); err != nil {
|
||||||
Handler: func(c *cluster.Cluster) http.HandlerFunc {
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
log.Error("htmx.Handler").
|
||||||
if err := view.ClusterInfo(c).Render(context.Background(), w); err != nil {
|
Str("uri", r.RequestURI).
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
Err(err).
|
||||||
log.Error("htmx.Handler").
|
Int("statusCode", http.StatusBadRequest).Send()
|
||||||
Str("uri", r.RequestURI).
|
}
|
||||||
Err(err).
|
})
|
||||||
Int("statusCode", http.StatusBadRequest).Send()
|
r.Get("/host/{hostname}", func(w http.ResponseWriter, r *http.Request) {
|
||||||
}
|
host, err := c.GetHost(r.PathValue("hostname"))
|
||||||
}
|
if err != nil {
|
||||||
},
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
},
|
log.Error("htmx.Handler").
|
||||||
{
|
Str("uri", r.RequestURI).
|
||||||
Method: http.MethodGet,
|
Err(err).
|
||||||
Path: "/host/{hostname}",
|
Int("statusCode", http.StatusBadRequest).
|
||||||
Handler: func(c *cluster.Cluster) http.HandlerFunc {
|
Send()
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
}
|
||||||
host, err := c.GetHost(r.PathValue("hostname"))
|
if err = view.HostInfo(host).Render(context.Background(), w); err != nil {
|
||||||
if err != nil {
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
log.Error("htmx.Handler").
|
||||||
log.Error("htmx.Handler").
|
Str("uri", r.RequestURI).
|
||||||
Str("uri", r.RequestURI).
|
Err(err).
|
||||||
Err(err).
|
Int("statusCode", http.StatusInternalServerError).
|
||||||
Int("statusCode", http.StatusBadRequest).
|
Send()
|
||||||
Send()
|
}
|
||||||
}
|
})
|
||||||
if err = view.HostInfo(host).Render(context.Background(), w); err != nil {
|
r.Get("/host/{hostname}/stats", func(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
host, err := c.GetHost(r.PathValue("hostname"))
|
||||||
log.Error("htmx.Handler").
|
if err != nil {
|
||||||
Str("uri", r.RequestURI).
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
Err(err).
|
log.Error("htmx.Handler").
|
||||||
Int("statusCode", http.StatusInternalServerError).
|
Str("uri", r.RequestURI).
|
||||||
Send()
|
Err(err).
|
||||||
}
|
Int("statusCode", http.StatusBadRequest).
|
||||||
}
|
Send()
|
||||||
},
|
}
|
||||||
},
|
if err = view.HostStats(host).Render(context.Background(), w); err != nil {
|
||||||
{
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
Method: http.MethodGet,
|
log.Error("htmx.Handler").
|
||||||
Path: "/host/{hostname}/stats",
|
Str("uri", r.RequestURI).
|
||||||
Handler: func(c *cluster.Cluster) http.HandlerFunc {
|
Err(err).
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
Int("statusCode", http.StatusInternalServerError).
|
||||||
host, err := c.GetHost(r.PathValue("hostname"))
|
Send()
|
||||||
if err != nil {
|
}
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
})
|
||||||
log.Error("htmx.Handler").
|
return r
|
||||||
Str("uri", r.RequestURI).
|
|
||||||
Err(err).
|
|
||||||
Int("statusCode", http.StatusBadRequest).
|
|
||||||
Send()
|
|
||||||
}
|
|
||||||
if err = view.HostStats(host).Render(context.Background(), w); err != nil {
|
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
log.Error("htmx.Handler").
|
|
||||||
Str("uri", r.RequestURI).
|
|
||||||
Err(err).
|
|
||||||
Int("statusCode", http.StatusInternalServerError).
|
|
||||||
Send()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,9 @@ import (
|
|||||||
func (s *Server) baseRoutes() {
|
func (s *Server) baseRoutes() {
|
||||||
// fileserver for static content
|
// fileserver for static content
|
||||||
fs := http.StripPrefix("/static", http.FileServer(http.Dir("public")))
|
fs := http.StripPrefix("/static", http.FileServer(http.Dir("public")))
|
||||||
s.mux.Handle("GET /static/*", fs)
|
s.r.Get("/static/*", fs.ServeHTTP)
|
||||||
|
|
||||||
// Root defaults to the cluster view
|
// Root defaults to the cluster view
|
||||||
s.mux.Handle("GET /", templ.Handler(layouts.Manager("ClustVirt", "libvirt made simple")))
|
s.r.Get("/", templ.Handler(layouts.Manager("ClustVirt", "libvirt made simple")).ServeHTTP)
|
||||||
s.mux.Handle("GET /about", templ.Handler(static.About()))
|
s.r.Get("/about", templ.Handler(static.About()).ServeHTTP)
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,10 @@ import (
|
|||||||
// a good choice to reduce dependencies, but does mean middleware needs to be implemented
|
// a good choice to reduce dependencies, but does mean middleware needs to be implemented
|
||||||
// in the server
|
// in the server
|
||||||
type Server struct {
|
type Server struct {
|
||||||
bindAddr string
|
bindAddr string
|
||||||
ssl bool
|
ssl bool
|
||||||
c *cluster.Cluster
|
c *cluster.Cluster
|
||||||
middleware []middleware.Middleware
|
r *router.Router
|
||||||
mux *http.ServeMux
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new HTTP Server instance.
|
// New creates a new HTTP Server instance.
|
||||||
@ -42,7 +41,7 @@ func (s *Server) Start() {
|
|||||||
Dur("upTime", time.Since(tstart)).
|
Dur("upTime", time.Since(tstart)).
|
||||||
Msg("http server stopped")
|
Msg("http server stopped")
|
||||||
}()
|
}()
|
||||||
s.mux = http.NewServeMux()
|
s.r = router.New()
|
||||||
|
|
||||||
indev, _ := os.LookupEnv("CLUSTVIRT_DEV")
|
indev, _ := os.LookupEnv("CLUSTVIRT_DEV")
|
||||||
indev = strings.ToLower(indev)
|
indev = strings.ToLower(indev)
|
||||||
@ -54,45 +53,20 @@ func (s *Server) Start() {
|
|||||||
case "yes":
|
case "yes":
|
||||||
fallthrough
|
fallthrough
|
||||||
case "on":
|
case "on":
|
||||||
s.AddMiddleware(middleware.NoCache)
|
s.r.AddMiddleware(middleware.NoCache)
|
||||||
s.mux.Handle("GET /_/debug", middleware.Profiler())
|
|
||||||
}
|
}
|
||||||
s.AddMiddleware(middleware.Logger)
|
s.r.AddMiddleware(middleware.Logger)
|
||||||
// Add routes
|
// Add routes
|
||||||
s.baseRoutes()
|
s.baseRoutes()
|
||||||
if err := s.AddSubRouter("/htmx", htmx.Htmx); err != nil {
|
if err := s.r.AddSubRouter("/htmx", htmx.Routes(s.c)); err != nil {
|
||||||
log.Error("server.Start").
|
log.Error("server.Start").
|
||||||
Str("subroute", "htmx").
|
Str("subroute", "htmx").
|
||||||
Err(err).Send()
|
Err(err).Send()
|
||||||
}
|
}
|
||||||
// Start the server
|
// Start the server
|
||||||
if err := http.ListenAndServe(s.bindAddr, s); err != nil {
|
if err := http.ListenAndServe(s.bindAddr, s.r); err != nil {
|
||||||
log.Error("router.Server.Start").
|
log.Error("router.Server.Start").
|
||||||
Str("bindaddr", s.bindAddr).
|
Str("bindaddr", s.bindAddr).
|
||||||
Err(err).Send()
|
Err(err).Send()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddMiddleware appends middleware to the chi router
|
|
||||||
func (s *Server) AddMiddleware(m ...middleware.Middleware) {
|
|
||||||
s.middleware = append(s.middleware, m...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddSubRouter attachs a SubRouter using it's MountTo method. This method
|
|
||||||
// needs the path prefix and the defined routes
|
|
||||||
func (s *Server) AddSubRouter(pfx string, sr router.SubRouter) error {
|
|
||||||
return sr.MountTo(pfx, s.c, s.mux)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServeHTTP implements the Handler interface
|
|
||||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|
||||||
s.chain().ServeHTTP(w, r)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) chain() http.Handler {
|
|
||||||
h := http.Handler(s.mux)
|
|
||||||
for i := range s.middleware {
|
|
||||||
h = s.middleware[len(s.middleware)-1-i](h)
|
|
||||||
}
|
|
||||||
return h
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package view
|
package view
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package components
|
package components
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package view
|
package view
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package layouts
|
package layouts
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package layouts
|
package layouts
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Code generated by templ - DO NOT EDIT.
|
// Code generated by templ - DO NOT EDIT.
|
||||||
|
|
||||||
// templ: version: v0.2.646
|
// templ: version: v0.2.648
|
||||||
package static
|
package static
|
||||||
|
|
||||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||||
|
Loading…
Reference in New Issue
Block a user