1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-11-26 08:01:37 +02:00

normalized builtin middlewares to return hook.Handler

This commit is contained in:
Gani Georgiev
2024-10-14 18:17:31 +03:00
parent 47d5ea3ce2
commit f9ee710cdd
3 changed files with 153 additions and 144 deletions

View File

@@ -83,21 +83,17 @@ func Serve(app core.App, config ServeConfig) error {
return err
}
pbRouter.Bind(&hook.Handler[*core.RequestEvent]{
Id: DefaultCorsMiddlewareId,
Func: CORSWithConfig(CORSConfig{
AllowOrigins: config.AllowedOrigins,
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
}),
Priority: DefaultCorsMiddlewarePriority,
})
pbRouter.Bind(CORSWithConfig(CORSConfig{
AllowOrigins: config.AllowedOrigins,
AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
}))
pbRouter.BindFunc(installerRedirect(app, config.DashboardPath))
pbRouter.GET(config.DashboardPath, Static(ui.DistDirFS, false)).
BindFunc(dashboardRemoveInstallerParam()).
BindFunc(dashboardCacheControl()).
BindFunc(Gzip())
Bind(Gzip())
// start http server
// ---