Skip to content

Instantly share code, notes, and snippets.

@crobby
Created September 28, 2016 17:48
Show Gist options
  • Save crobby/ea93df1129b4009a830834f2f1af590a to your computer and use it in GitHub Desktop.
Save crobby/ea93df1129b4009a830834f2f1af590a to your computer and use it in GitHub Desktop.
// The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
// The middleware executes after routing but before authentication, binding and validation
func setupMiddlewares(handler http.Handler) http.Handler {
corsHeaders := cors.New(cors.Options{
AllowedOrigins: []string{"*"},
AllowCredentials: true,
AllowedMethods: []string{"GET", "HEAD", "POST", "DELETE", "PUT"},
OptionsPassthrough: false, // I have also tried true here
})
handler = corsHeaders.Handler(handler)
return handler
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment