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

Feature Request: Middleware Handling #110

Closed
mathvav opened this issue Jul 17, 2015 · 1 comment
Closed

Feature Request: Middleware Handling #110

mathvav opened this issue Jul 17, 2015 · 1 comment

Comments

@mathvav
Copy link

mathvav commented Jul 17, 2015

I know that this has traditionally been a task of something like Negroni or Martini, but I think it's a good idea to instead handle it in the mux layer.

For example, say I create a subrouter like this:

r := mux.NewRouter()
r.HandleFunc("/", IndexHandler)
s := r.PathPrefix("/client-data").Subrouter()
s.HandleFunc("/", ClientDataHandler)

Life is good. If I need a piece of middleware for Gzip, I can add that to Negroni. However, let's say that I need to use an authentication middleware for anything beginning with "/client-data," I need to explicitly call a function in every handler.

It'd be really nice to just be able to pop a piece of middleware onto the subrouter. Is this type of thing beyond the scope of the project? Is there another way for this that I am missing?

@mathvav
Copy link
Author

mathvav commented Jul 17, 2015

Sorry, didn't realize the is-open flag was the default on GitHub and didn't notice #36. However, I don't understand why you don't want this... API complexity is understandable, but I think that this would be really helpful.

The "opinionated" argument doesn't really stand since you don't have to use the middleware. Plus, there's no way to integrate anything into a subrouter, so it's painful to "implement it elsewhere."

@mathvav mathvav closed this as completed Jul 17, 2015
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

No branches or pull requests

1 participant