mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
feat(api): add new route for listing routes by provider
This commit is contained in:
parent
48823a860f
commit
26938eb6ed
2 changed files with 11 additions and 0 deletions
|
@ -20,6 +20,7 @@ import (
|
|||
const (
|
||||
ListRoute = "route"
|
||||
ListRoutes = "routes"
|
||||
ListRoutesByProvider = "routes_by_provider"
|
||||
ListFiles = "files"
|
||||
ListMiddlewares = "middlewares"
|
||||
ListMiddlewareTraces = "middleware_trace"
|
||||
|
@ -48,6 +49,8 @@ func List(cfg config.ConfigInstance, w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
case ListRoutes:
|
||||
gphttp.RespondJSON(w, r, routes.ByAlias(route.RouteType(r.FormValue("type"))))
|
||||
case ListRoutesByProvider:
|
||||
gphttp.RespondJSON(w, r, routes.ByProvider())
|
||||
case ListFiles:
|
||||
listFiles(w, r)
|
||||
case ListMiddlewares:
|
||||
|
|
|
@ -135,3 +135,11 @@ func ByAlias(typeFilter ...route.RouteType) map[string]Route {
|
|||
}
|
||||
return rts
|
||||
}
|
||||
|
||||
func ByProvider() map[string][]Route {
|
||||
rts := make(map[string][]Route)
|
||||
for _, r := range HTTP.Iter {
|
||||
rts[r.ProviderName()] = append(rts[r.ProviderName()], r)
|
||||
}
|
||||
return rts
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue