fixed status response
This commit is contained in:
parent
d768d3edac
commit
16c6eabe13
@ -101,7 +101,7 @@ func (s *Server) apiRegisterEndpoints(
|
||||
router.GET("/api/v1/routeservers",
|
||||
endpoint(s.apiRouteServersList))
|
||||
router.GET("/api/v1/routeservers/:id/status",
|
||||
endpoint(s.apiStatus))
|
||||
endpoint(s.apiRouteServerStatusShow))
|
||||
router.GET("/api/v1/routeservers/:id/neighbors",
|
||||
endpoint(s.apiNeighborsList))
|
||||
router.GET("/api/v1/routeservers/:id/neighbors/:neighborId/routes",
|
||||
|
@ -20,30 +20,6 @@ func (s *Server) apiStatusShow(
|
||||
return status, err
|
||||
}
|
||||
|
||||
// Handle status
|
||||
func (s *Server) apiStatus(
|
||||
ctx context.Context,
|
||||
_req *http.Request,
|
||||
params httprouter.Params,
|
||||
) (response, error) {
|
||||
rsID, err := validateSourceID(params.ByName("id"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
source := s.cfg.SourceInstanceByID(rsID)
|
||||
if source == nil {
|
||||
return nil, ErrSourceNotFound
|
||||
}
|
||||
|
||||
result, err := source.Status(ctx)
|
||||
if err != nil {
|
||||
s.logSourceError("status", rsID, err)
|
||||
}
|
||||
|
||||
return result, err
|
||||
}
|
||||
|
||||
// Handle Config Endpoint
|
||||
func (s *Server) apiConfigShow(
|
||||
_ctx context.Context,
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/julienschmidt/httprouter"
|
||||
|
||||
"github.com/alice-lg/alice-lg/pkg/api"
|
||||
"github.com/alice-lg/alice-lg/pkg/config"
|
||||
)
|
||||
|
||||
// Handle RouteServers List
|
||||
@ -41,3 +42,30 @@ func (s *Server) apiRouteServersList(
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// Handle route server status
|
||||
func (s *Server) apiRouteServerStatusShow(
|
||||
ctx context.Context,
|
||||
_req *http.Request,
|
||||
params httprouter.Params,
|
||||
) (response, error) {
|
||||
rsID, err := validateSourceID(params.ByName("id"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
source := s.cfg.SourceInstanceByID(rsID)
|
||||
if source == nil {
|
||||
return nil, ErrSourceNotFound
|
||||
}
|
||||
|
||||
result, err := source.Status(ctx)
|
||||
if err != nil {
|
||||
s.logSourceError("status", rsID, err)
|
||||
}
|
||||
if result != nil {
|
||||
result.Meta.Version = config.Version
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user