diff --git a/server/endpoints.go b/server/endpoints.go new file mode 100644 index 0000000000000000000000000000000000000000..fbc23d957dd607c7953c1763337ca9a4ccf8af01 --- /dev/null +++ b/server/endpoints.go @@ -0,0 +1,25 @@ +// Package server implements the server. +package server + +import ( + "context" + + "git.lyda.ie/kevin/boxes/api" +) + +// Endpoints implements the endpoints. +type Endpoints struct { +} + +// NewEndpoints returns a new Endpoints structure. +func NewEndpoints() *Endpoints { + return &Endpoints{} +} + +// GetLocations returns a list of locations. +func (ep *Endpoints) GetLocations(_ context.Context, _ api.GetLocationsRequestObject) (api.GetLocationsResponseObject, error) { + loc := []api.Location{} + return api.GetLocations200JSONResponse{ + LocationsJSONResponse: loc, + }, nil +} diff --git a/server/server.go b/server/server.go new file mode 100644 index 0000000000000000000000000000000000000000..3f09009428fd725a487304b3a8978fa05ef14d4d --- /dev/null +++ b/server/server.go @@ -0,0 +1,19 @@ +// Package server implements the server. +package server + +import ( + "fmt" + + "git.lyda.ie/kevin/boxes/api" + "github.com/labstack/echo/v4" + "github.com/spf13/cobra" +) + +// StartServer starts the metrics and API servers. +func StartServer(_ *cobra.Command, _ []string) { + e := echo.New() + endpoints := NewEndpoints() + server := api.NewStrictHandler(endpoints, nil) + api.RegisterHandlers(e, server) + fmt.Printf("Server exited with: %+v\n", e.Start(":8070")) +}