-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
34 lines (25 loc) · 747 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"log"
"github.com/gobeli/pocketbase-htmx/app"
"github.com/gobeli/pocketbase-htmx/auth"
"github.com/gobeli/pocketbase-htmx/middleware"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/core"
)
const AuthCookieName = "Auth"
func main() {
pb := pocketbase.New()
// serves static files from the provided public dir (if exists)
pb.OnBeforeServe().Add(func(e *core.ServeEvent) error {
e.Router.Static("/public", "public")
authGroup := e.Router.Group("/auth", middleware.LoadAuthContextFromCookie(pb))
auth.RegisterLoginRoutes(e, *authGroup)
auth.RegisterRegisterRoutes(e, *authGroup)
app.InitAppRoutes(e, pb)
return nil
})
if err := pb.Start(); err != nil {
log.Fatal(err)
}
}