Skip to content

Instantly share code, notes, and snippets.

@marawannwh
Created March 11, 2016 14:42
Show Gist options
  • Save marawannwh/cc5df3ca6df7c1706423 to your computer and use it in GitHub Desktop.
Save marawannwh/cc5df3ca6df7c1706423 to your computer and use it in GitHub Desktop.
// User Code
type User struct {
Id int
Name string
}
// implement auth interface
func (u User) Authenticate(r *http.Request) (interface{}, error) {
// auth
return u, nil
}
func main(){
framework.UseAuth(User{})
}
// Framework Code
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
User, err := user.Authenticate(r)
response := h.Fn(&request{User: User})
}
// the request provided to the user has a User field
// i want the user to be able to call User.Name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment