clean pb examples

This commit is contained in:
Kristian 2023-07-30 03:55:58 +02:00
parent ba77f04e30
commit a5517264a7
2 changed files with 9 additions and 27 deletions

View File

@ -1,36 +1,18 @@
package pb
import (
"net/http"
"github.com/labstack/echo/v5"
"github.com/pocketbase/pocketbase"
"github.com/pocketbase/pocketbase/apis"
"github.com/pocketbase/pocketbase/core"
"github.com/charmbracelet/log"
"github.com/pocketbase/pocketbase"
)
func Run() {
app := pocketbase.New()
app := pocketbase.New()
app.OnBeforeServe().Add(func(e *core.ServeEvent) error {
// add new "GET /hello" route to the app router (echo)
e.Router.AddRoute(echo.Route{
Method: http.MethodGet,
Path: "/hello",
Handler: func(c echo.Context) error {
return c.String(200, "Hello world!")
},
Middlewares: []echo.MiddlewareFunc{
apis.ActivityLogger(app),
},
})
// Start the PocketBase server in a goroutine.
func() {
if err := app.Start(); err != nil {
log.Fatal(err)
}
}()
return nil
})
if err := app.Start(); err != nil {
log.Fatal(err)
}
}

Binary file not shown.