mirror of
https://codeberg.org/PLG-Development/PLG-MuDiCS
synced 2026-07-06 00:47:09 +00:00
chore: basic control template
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"plg-mudics-control/frontend"
|
||||
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
)
|
||||
|
||||
func main() {
|
||||
e := echo.New()
|
||||
|
||||
// Serve the embedded SvelteKit frontend
|
||||
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||
Filesystem: http.FS(frontend.BuildDirFS),
|
||||
HTML5: true,
|
||||
}))
|
||||
|
||||
// Servers all API endpoints, e.g. our custom logic
|
||||
apiGroup := e.Group("/api")
|
||||
apiGroup.GET("/ping", func(ctx echo.Context) error {
|
||||
return ctx.String(http.StatusOK, "pong")
|
||||
})
|
||||
|
||||
err := e.Start(":1323")
|
||||
if err != nil {
|
||||
slog.Error("Failed to start Echo Webserver", "error", err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user