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",
|
router.GET("/api/v1/routeservers",
|
||||||
endpoint(s.apiRouteServersList))
|
endpoint(s.apiRouteServersList))
|
||||||
router.GET("/api/v1/routeservers/:id/status",
|
router.GET("/api/v1/routeservers/:id/status",
|
||||||
endpoint(s.apiStatus))
|
endpoint(s.apiRouteServerStatusShow))
|
||||||
router.GET("/api/v1/routeservers/:id/neighbors",
|
router.GET("/api/v1/routeservers/:id/neighbors",
|
||||||
endpoint(s.apiNeighborsList))
|
endpoint(s.apiNeighborsList))
|
||||||
router.GET("/api/v1/routeservers/:id/neighbors/:neighborId/routes",
|
router.GET("/api/v1/routeservers/:id/neighbors/:neighborId/routes",
|
||||||
|
@ -20,30 +20,6 @@ func (s *Server) apiStatusShow(
|
|||||||
return status, err
|
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
|
// Handle Config Endpoint
|
||||||
func (s *Server) apiConfigShow(
|
func (s *Server) apiConfigShow(
|
||||||
_ctx context.Context,
|
_ctx context.Context,
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/julienschmidt/httprouter"
|
"github.com/julienschmidt/httprouter"
|
||||||
|
|
||||||
"github.com/alice-lg/alice-lg/pkg/api"
|
"github.com/alice-lg/alice-lg/pkg/api"
|
||||||
|
"github.com/alice-lg/alice-lg/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Handle RouteServers List
|
// Handle RouteServers List
|
||||||
@ -41,3 +42,30 @@ func (s *Server) apiRouteServersList(
|
|||||||
|
|
||||||
return response, nil
|
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