diff --git a/api/system.go b/api/system.go deleted file mode 100644 index 6b7c3e6..0000000 --- a/api/system.go +++ /dev/null @@ -1,7 +0,0 @@ -package api - -import "github.com/boojack/shortify/server/profile" - -type SystemStatus struct { - Profile *profile.Profile `json:"profile"` -} diff --git a/api/v1/system.go b/api/v1/system.go new file mode 100644 index 0000000..38ecf76 --- /dev/null +++ b/api/v1/system.go @@ -0,0 +1,26 @@ +package v1 + +import ( + "net/http" + + "github.com/boojack/shortify/server/profile" + "github.com/labstack/echo/v4" +) + +type SystemStatus struct { + Profile *profile.Profile `json:"profile"` +} + +func (s *APIV1Service) registerSystemRoutes(g *echo.Group) { + g.GET("/ping", func(c echo.Context) error { + return c.JSON(http.StatusOK, s.Profile) + }) + + g.GET("/status", func(c echo.Context) error { + systemStatus := SystemStatus{ + Profile: s.Profile, + } + + return c.JSON(http.StatusOK, systemStatus) + }) +} diff --git a/api/v1/v1.go b/api/v1/v1.go index 41e0043..57684f4 100644 --- a/api/v1/v1.go +++ b/api/v1/v1.go @@ -20,6 +20,7 @@ func NewAPIV1Service(profile *profile.Profile, store *store.Store) *APIV1Service } func (s *APIV1Service) Start(apiV1Group *echo.Group, secret string) { + s.registerSystemRoutes(apiV1Group) s.registerAuthRoutes(apiV1Group, secret) s.registerUserRoutes(apiV1Group) s.registerWorkspaceRoutes(apiV1Group) diff --git a/server/profile/profile.go b/server/profile/profile.go index ba9b352..809ac0d 100644 --- a/server/profile/profile.go +++ b/server/profile/profile.go @@ -12,14 +12,14 @@ import ( // Profile is the configuration to start main server. type Profile struct { + // Data is the data directory + Data string `json:"-"` + // DSN points to where Shortify stores its own data + DSN string `json:"-"` // Mode can be "prod" or "dev" Mode string `json:"mode"` // Port is the binding port for server Port int `json:"port"` - // Data is the data directory - Data string `json:"data"` - // DSN points to where Shortify stores its own data - DSN string `json:"dsn"` // Version is the current version of server Version string `json:"version"` } diff --git a/server/server.go b/server/server.go index 6b43a2f..306fb4c 100644 --- a/server/server.go +++ b/server/server.go @@ -64,7 +64,6 @@ func NewServer(profile *profile.Profile, store *store.Store) (*Server, error) { apiGroup.Use(func(next echo.HandlerFunc) echo.HandlerFunc { return JWTMiddleware(s, next, string(secret)) }) - s.registerSystemRoutes(apiGroup) s.registerWorkspaceUserRoutes(apiGroup) s.registerShortcutRoutes(apiGroup) diff --git a/server/system.go b/server/system.go deleted file mode 100644 index dd64a5a..0000000 --- a/server/system.go +++ /dev/null @@ -1,23 +0,0 @@ -package server - -import ( - "net/http" - - "github.com/boojack/shortify/api" - - "github.com/labstack/echo/v4" -) - -func (s *Server) registerSystemRoutes(g *echo.Group) { - g.GET("/ping", func(c echo.Context) error { - return c.JSON(http.StatusOK, composeResponse(s.Profile)) - }) - - g.GET("/status", func(c echo.Context) error { - systemStatus := api.SystemStatus{ - Profile: s.Profile, - } - - return c.JSON(http.StatusOK, composeResponse(systemStatus)) - }) -}