auth
auth/oauth2.go
Add request helpers. Fix a typo in the requestErrConflict constant. Create a response type that is used to build responses before sending them down the wire. Create vars for a few common types of error responses that never change. Create a negotiate middleware function that will respond with a 406 error if the client requests an encoding that we can't support. Create an encode helper that determines the requested encoding and uses it to send the data down the wire. Move our wrap middleware from the oauth2.go file to the request.go file, where it's more likely to be looked for.
1.1 --- a/oauth2.go Sun Dec 14 16:56:12 2014 -0500 1.2 +++ b/oauth2.go Sun Dec 14 17:00:31 2014 -0500 1.3 @@ -126,12 +126,6 @@ 1.4 return true 1.5 } 1.6 1.7 -func wrap(context Context, f func(w http.ResponseWriter, r *http.Request, context Context)) http.Handler { 1.8 - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 1.9 - f(w, r, context) 1.10 - }) 1.11 -} 1.12 - 1.13 // RegisterOAuth2 adds handlers to the passed router to handle the OAuth2 endpoints. 1.14 func RegisterOAuth2(r *mux.Router, context Context) { 1.15 r.Handle("/authorize", wrap(context, GetAuthorizationCodeHandler))