-
Notifications
You must be signed in to change notification settings - Fork 0
Remove Echo dependency and upgrade to Go 1.24 #872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,12 +16,10 @@ package cmd | |
|
|
||
| import ( | ||
| "io/fs" | ||
| "net/http" | ||
| "os" | ||
| "path/filepath" | ||
|
|
||
| "github.com/kindlyops/vbs/embeddy" | ||
| "github.com/labstack/echo/v5" | ||
| "github.com/muesli/coral" | ||
| "github.com/pocketbase/pocketbase" | ||
| "github.com/pocketbase/pocketbase/apis" | ||
|
|
@@ -52,54 +50,30 @@ func flyServer(cmd *coral.Command, args []string) { | |
| } | ||
|
|
||
| log.Debug().Msgf("running pocketbase with data dir %s\n", configDir) | ||
| app := pocketbase.NewWithConfig(&pocketbase.Config{ | ||
| app := pocketbase.NewWithConfig(pocketbase.Config{ | ||
| DefaultDataDir: configDir, | ||
| }) | ||
|
|
||
| migrationsDir := "" // default to "pb_migrations" (for js) and "migrations" (for go) | ||
|
|
||
| // register the `migrate` command | ||
| migratecmd.MustRegister(app, app.RootCmd, &migratecmd.Options{ | ||
| TemplateLang: migratecmd.TemplateLangGo, // or migratecmd.TemplateLangJS | ||
| migratecmd.MustRegister(app, app.RootCmd, migratecmd.Config{ | ||
| TemplateLang: migratecmd.TemplateLangGo, | ||
| Dir: migrationsDir, | ||
| Automigrate: true, | ||
| }) | ||
|
|
||
| app.OnBeforeServe().Add(func(e *core.ServeEvent) error { | ||
| app.OnServe().BindFunc(func(e *core.ServeEvent) error { | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
| public, err := fs.Sub(embeddy.GetNextFS(), "public") | ||
| if err != nil { | ||
| log.Fatal().Err(err).Msg("Could not access embedded public directory") | ||
| } | ||
| assetHandler := http.FileServer(http.FS(public)) | ||
| e.Router.AddRoute(echo.Route{ | ||
| Method: http.MethodGet, | ||
| Path: "/*", | ||
| Handler: echo.WrapHandler(assetHandler), | ||
| Middlewares: []echo.MiddlewareFunc{ | ||
| apis.ActivityLogger(app), | ||
| //apis.RequireAdminAuth(), | ||
| }, | ||
| }) | ||
|
|
||
| e.Router.AddRoute(echo.Route{ | ||
| Method: http.MethodPost, | ||
| Path: "/api/switcher/*", | ||
| Middlewares: []echo.MiddlewareFunc{ | ||
| apis.ActivityLogger(app), | ||
| }, | ||
| Handler: echo.WrapHandler(&Switcher{}), | ||
| }) | ||
|
|
||
| e.Router.AddRoute(echo.Route{ | ||
| Method: http.MethodPost, | ||
| Path: "/api/light/*", | ||
| Middlewares: []echo.MiddlewareFunc{ | ||
| apis.ActivityLogger(app), | ||
| }, | ||
| Handler: echo.WrapHandler(&Lighting{}), | ||
| }) | ||
|
|
||
| return nil | ||
|
|
||
| e.Router.GET("/{path...}", apis.Static(public, true)) | ||
| e.Router.POST("/api/switcher/{path...}", apis.WrapStdHandler(&Switcher{})) | ||
| e.Router.POST("/api/light/{path...}", apis.WrapStdHandler(&Lighting{})) | ||
|
|
||
| return e.Next() | ||
| }) | ||
|
|
||
| if err := app.Start(); err != nil { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ import ( | |
|
|
||
| "github.com/hypebeast/go-osc/osc" | ||
| "github.com/kindlyops/vbs/embeddy" | ||
| "github.com/labstack/echo/v5" | ||
| "github.com/muesli/coral" | ||
| "github.com/rs/zerolog/log" | ||
| "github.com/spf13/viper" | ||
|
|
@@ -53,14 +52,14 @@ func lightingBridge(cmd *coral.Command, args []string) { | |
| assetHandler := http.FileServer(http.FS(public)) | ||
|
|
||
| log.Debug().Msgf("Starting HTTP server at: http://%s\n", listenAddr) | ||
| e := echo.New() | ||
| e.GET("/*", echo.WrapHandler(assetHandler)) | ||
| e.POST("/api/switcher/*", echo.WrapHandler(&Switcher{})) | ||
| e.POST("/api/light/*", echo.WrapHandler(&Lighting{})) | ||
| err = e.Start(listenAddr) | ||
| mux := http.NewServeMux() | ||
| mux.Handle("GET /{path...}", assetHandler) | ||
| mux.Handle("POST /api/switcher/{path...}", &Switcher{}) | ||
| mux.Handle("POST /api/light/{path...}", &Lighting{}) | ||
| err = http.ListenAndServe(listenAddr, mux) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚫 [golangci] reported by reviewdog 🐶 |
||
|
|
||
| if err != nil { | ||
| log.Error().Err(err).Msg("error from echo.Start") | ||
| log.Error().Err(err).Msg("error from http.ListenAndServe") | ||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚫 [golangci] reported by reviewdog 🐶
pocketbase.Config is missing fields HideStartBanner, DefaultDev, DefaultEncryptionEnv, DefaultQueryTimeout, DataMaxOpenConns, DataMaxIdleConns, AuxMaxOpenConns, AuxMaxIdleConns, DBConnect (exhaustruct)