Skip to content

Commit

Permalink
fix(api): handleRefRoutes should refer to username rather than
Browse files Browse the repository at this point in the history
`peername`
  • Loading branch information
ramfox committed Apr 29, 2021
1 parent 967b708 commit 644f706
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@ func newrefRouteParams(e lib.APIEndpoint, sr bool, sel bool, methods ...string)
func handleRefRoute(m *mux.Router, p refRouteParams, f http.HandlerFunc) {
routes := []string{
p.Endpoint.String(),
fmt.Sprintf("%s/%s", p.Endpoint, "{peername}/{name}"),
fmt.Sprintf("%s/%s", p.Endpoint, "{username}/{name}"),
}
if p.Selector {
routes = append(routes, fmt.Sprintf("%s/%s", p.Endpoint, "{peername}/{name}/{selector}"))
routes = append(routes, fmt.Sprintf("%s/%s", p.Endpoint, "{username}/{name}/{selector}"))
}
if !p.ShortRef {
routes = append(routes, fmt.Sprintf("%s/%s", p.Endpoint, "{peername}/{name}/at/{fs}/{hash}"))
routes = append(routes, fmt.Sprintf("%s/%s", p.Endpoint, "{username}/{name}/at/{fs}/{hash}"))
if p.Selector {
routes = append(routes, fmt.Sprintf("%s/%s", p.Endpoint, "{peername}/{name}/at/{fs}/{hash}/{selector}"))
routes = append(routes, fmt.Sprintf("%s/%s", p.Endpoint, "{username}/{name}/at/{fs}/{hash}/{selector}"))
}
}

Expand Down Expand Up @@ -222,7 +222,7 @@ func NewServerRoutes(s Server) *mux.Router {
m.Handle(lib.AEWebUI.String(), s.Middleware(WebuiHandler))
}
// non POST/json dataset endpoints
routeParams = newrefRouteParams(lib.AEGet, false, true, http.MethodGet, http.MethodPost)
routeParams = newrefRouteParams(lib.AEGet, false, true, http.MethodGet)
handleRefRoute(m, routeParams, s.Middleware(GetHandler(s.Instance, lib.AEGet.String())))
m.Handle(lib.AEUnpack.String(), s.Middleware(UnpackHandler(lib.AEUnpack.NoTrailingSlash())))
// sync/protocol endpoints
Expand Down

0 comments on commit 644f706

Please sign in to comment.