Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No Routes Registered for PUT #104

Closed
mohammed90 opened this issue May 30, 2019 · 0 comments · Fixed by #106
Closed

No Routes Registered for PUT #104

mohammed90 opened this issue May 30, 2019 · 0 comments · Fixed by #106

Comments

@mohammed90
Copy link
Contributor

As I'm writing the integration test for #83, I ran into PUT calls returning HTTP 405, which seems reasonable because the code never registers routes for PUT and only does so for PATCH. However, the API documentation specifies that every every route accepting PATCH also accepts PUT.

We can:

  • Removing references of PUT in the documentation
  • Add support for PUT

Either of those solutions wouldn't be a breaking change. Which one is preferred?

Here are the relevant files segments.

routes = append(routes,
route.Get("/").
SecuredWith(route.Unsecured()).
Handle(handlers.GetRoot(app)),
route.Get("/jwks").
SecuredWith(route.Unsecured()).
Handle(handlers.GetJWKs(app)),
route.Get("/configuration").
SecuredWith(route.Unsecured()).
Handle(handlers.GetConfiguration(app)),
route.Get("/metrics").
SecuredWith(authentication).
Handle(promhttp.Handler()),
route.Post("/accounts/import").
SecuredWith(authentication).
Handle(handlers.PostAccountsImport(app)),
route.Get("/accounts/{id:[0-9]+}").
SecuredWith(authentication).
Handle(handlers.GetAccount(app)),
route.Patch("/accounts/{id:[0-9]+}").
SecuredWith(authentication).
Handle(handlers.PatchAccount(app)),
route.Patch("/accounts/{id:[0-9]+}/lock").
SecuredWith(authentication).
Handle(handlers.PatchAccountLock(app)),
route.Patch("/accounts/{id:[0-9]+}/unlock").
SecuredWith(authentication).
Handle(handlers.PatchAccountUnlock(app)),
route.Patch("/accounts/{id:[0-9]+}/expire_password").
SecuredWith(authentication).
Handle(handlers.PatchAccountExpirePassword(app)),
route.Delete("/accounts/{id:[0-9]+}").
SecuredWith(authentication).
Handle(handlers.DeleteAccount(app)),
)

type SecurityHandler func(http.Handler) http.Handler
// Post creates a new POST route. A security handler must be registered next.
func Post(tpl string) *Route {
return &Route{Verb: "POST", Tpl: tpl}
}
// Get creates a new GET route. A security handler must be registered next.
func Get(tpl string) *Route {
return &Route{Verb: "GET", Tpl: tpl}
}
// Delete creates a new DELETE route. A security handler must be registered next.
func Delete(tpl string) *Route {
return &Route{Verb: "DELETE", Tpl: tpl}
}
// Patch creates a new PATCH route. A security handler must be registered next.
func Patch(tpl string) *Route {
return &Route{Verb: "PATCH", Tpl: tpl}
}
// Route is an incomplete Route comprising only verb and path (as a gorilla/mux template). It must
// next be `SecuredWith`.
type Route struct {
Verb string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant