| 12345678910111213141516171819202122 |
- // Package web contains HTTP handlers, middleware, and embedded static assets.
- package web
- import (
- "embed"
- "io/fs"
- "net/http"
- "github.com/pocketbase/pocketbase/core"
- )
- //go:embed static
- var staticFiles embed.FS
- // RegisterStatic registers the /static/* route serving embedded Bulma and htmx assets.
- func RegisterStatic(e *core.ServeEvent) {
- sub, _ := fs.Sub(staticFiles, "static")
- e.Router.GET("/static/{path...}", func(re *core.RequestEvent) error {
- http.StripPrefix("/static", http.FileServerFS(sub)).ServeHTTP(re.Response, re.Request)
- return nil
- })
- }
|