feat: migrate system to api v1

This commit is contained in:
Steven
2023-06-20 17:15:12 +08:00
parent 96704162d8
commit 24d42694c8
6 changed files with 31 additions and 35 deletions

View File

@ -1,7 +0,0 @@
package api
import "github.com/boojack/shortify/server/profile"
type SystemStatus struct {
Profile *profile.Profile `json:"profile"`
}

26
api/v1/system.go Normal file
View File

@ -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)
})
}

View File

@ -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)