Serve pb_public as a static asset
This commit is contained in:
parent
d43103570e
commit
df6369b9ad
1 changed files with 8 additions and 0 deletions
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/pocketbase/dbx"
|
"github.com/pocketbase/dbx"
|
||||||
|
|
@ -29,10 +30,17 @@ type Project struct {
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
app := pocketbase.New()
|
app := pocketbase.New()
|
||||||
|
|
||||||
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
|
migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{
|
||||||
Automigrate: false,
|
Automigrate: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
app.OnServe().BindFunc(func(se *core.ServeEvent) error {
|
||||||
|
se.Router.GET("/{path...}", apis.Static(os.DirFS("pb_public"), false))
|
||||||
|
|
||||||
|
return se.Next()
|
||||||
|
})
|
||||||
|
|
||||||
app.OnServe().BindFunc(func(e *core.ServeEvent) error {
|
app.OnServe().BindFunc(func(e *core.ServeEvent) error {
|
||||||
e.Router.GET("/api/hours/{organisation}/{year}/{month}", func(c *core.RequestEvent) error {
|
e.Router.GET("/api/hours/{organisation}/{year}/{month}", func(c *core.RequestEvent) error {
|
||||||
year := c.Request.PathValue("year")
|
year := c.Request.PathValue("year")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue