Created
March 11, 2016 14:42
-
-
Save marawannwh/cc5df3ca6df7c1706423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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