Skip to content

Instantly share code, notes, and snippets.

@cthom06
Created January 16, 2012 02:48
Show Gist options
  • Save cthom06/1618776 to your computer and use it in GitHub Desktop.
Save cthom06/1618776 to your computer and use it in GitHub Desktop.
func wrapHandler(f func(user, request), perm int) func(request) {
return func(r request) {
user := getuser(r)
if user.priv < perm {
write("no permission foo'!")
} else {
f(user, r)
}
}
}
func userPage(user, request) { ... }
http.Handle("/someurl", wrapHandler(userPage, 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment