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

Be able to set common handlers #8

Open
rjourde opened this issue Dec 19, 2014 · 2 comments
Open

Be able to set common handlers #8

rjourde opened this issue Dec 19, 2014 · 2 comments

Comments

@rjourde
Copy link
Contributor

rjourde commented Dec 19, 2014

Now:

  r := new(route.Router)
  r.HandleFunc("/users/?", errorHandler(authorizeHandler(usersHandler)))
  r.HandleFunc("/users/[0-9]+/?", errorHandler(authorizeHandler(userHandler)))
  r.HandleFunc("/users/[0-9]+/friends/[a-zA-Z]+/?", errorHandler(authorizeHandler(friendHandler)))

After:

  r := new(route.Router)
  r.commonHandlers = [errorHandler, authorizeHandler]
  r.HandleFunc("/users/?", usersHandler)
  r.HandleFunc("/users/[0-9]+/?", userHandler)
  r.HandleFunc("/users/[0-9]+/friends/[a-zA-Z]+/?", friendHandler)
@santiaago
Copy link
Member

I like this 👍

@santiaago
Copy link
Member

I am thinking if this work should be in this package or in a taironas/filers or taironas/authorize package.

What do you think?

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

No branches or pull requests

2 participants