added api version

This commit is contained in:
Matthias Hannig 2018-10-03 17:59:07 +02:00
parent 1c57264e6d
commit dbf88195b9

View File

@ -21,16 +21,16 @@ import (
// Endpoints: // Endpoints:
// //
// Config // Config
// Show /api/config // Show /api/v1/config
// //
// Routeservers // Routeservers
// List /api/routeservers // List /api/v1/routeservers
// Status /api/routeservers/:id/status // Status /api/v1/routeservers/:id/status
// Neighbors /api/routeservers/:id/neighbours // Neighbors /api/v1/routeservers/:id/neighbours
// Routes /api/routeservers/:id/neighbours/:neighbourId/routes // Routes /api/v1/routeservers/:id/neighbours/:neighbourId/routes
// //
// Querying // Querying
// LookupPrefix /api/routeservers/:id/lookup/prefix?q=<prefix> // LookupPrefix /api/v1/routeservers/:id/lookup/prefix?q=<prefix>
// //
type apiEndpoint func(*http.Request, httprouter.Params) (api.Response, error) type apiEndpoint func(*http.Request, httprouter.Params) (api.Response, error)
@ -88,28 +88,28 @@ func endpoint(wrapped apiEndpoint) httprouter.Handle {
func apiRegisterEndpoints(router *httprouter.Router) error { func apiRegisterEndpoints(router *httprouter.Router) error {
// Meta // Meta
router.GET("/api/status", endpoint(apiStatusShow)) router.GET("/api/v1/status", endpoint(apiStatusShow))
router.GET("/api/config", endpoint(apiConfigShow)) router.GET("/api/v1/config", endpoint(apiConfigShow))
// Routeservers // Routeservers
router.GET("/api/routeservers", router.GET("/api/v1/routeservers",
endpoint(apiRouteserversList)) endpoint(apiRouteserversList))
router.GET("/api/routeservers/:id/status", router.GET("/api/v1/routeservers/:id/status",
endpoint(apiStatus)) endpoint(apiStatus))
router.GET("/api/routeservers/:id/neighbours", router.GET("/api/v1/routeservers/:id/neighbours",
endpoint(apiNeighborsList)) endpoint(apiNeighborsList))
router.GET("/api/routeservers/:id/neighbours/:neighbourId/routes", router.GET("/api/v1/routeservers/:id/neighbours/:neighbourId/routes",
endpoint(apiRoutesList)) endpoint(apiRoutesList))
router.GET("/api/routeservers/:id/neighbours/:neighbourId/routes/received", router.GET("/api/v1/routeservers/:id/neighbours/:neighbourId/routes/received",
endpoint(apiRoutesListReceived)) endpoint(apiRoutesListReceived))
router.GET("/api/routeservers/:id/neighbours/:neighbourId/routes/filtered", router.GET("/api/v1/routeservers/:id/neighbours/:neighbourId/routes/filtered",
endpoint(apiRoutesListFiltered)) endpoint(apiRoutesListFiltered))
router.GET("/api/routeservers/:id/neighbours/:neighbourId/routes/not-exported", router.GET("/api/v1/routeservers/:id/neighbours/:neighbourId/routes/not-exported",
endpoint(apiRoutesListNotExported)) endpoint(apiRoutesListNotExported))
// Querying // Querying
if AliceConfig.Server.EnablePrefixLookup == true { if AliceConfig.Server.EnablePrefixLookup == true {
router.GET("/api/lookup/prefix", router.GET("/api/v1/lookup/prefix",
endpoint(apiLookupPrefixGlobal)) endpoint(apiLookupPrefixGlobal))
} }