Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cors] add OPTIONS status code + fix function typo #132

Merged
merged 1 commit into from
Sep 14, 2018

Conversation

commit-master
Copy link
Contributor

I believe we should handle the StatusCode when receiving OPTIONS requests. Best practice is to respond with a 200 or 204 code.

200 code seems to be the most used since it seems to work across any browser:
https://stackoverflow.com/questions/46026409/what-are-proper-status-codes-for-cors-preflight-requests

We should let the user override this status code this is why I exposed the OptionStatusCode method that take an int.

@commit-master commit-master force-pushed the fix-options-status-code branch 4 times, most recently from 2b29c06 to f2fe3ba Compare August 29, 2018 08:11
@elithrar elithrar self-assigned this Sep 11, 2018
@elithrar elithrar self-requested a review September 11, 2018 11:41
cors.go Outdated Show resolved Hide resolved
cors.go Outdated
// ExposeHeaders can be used to specify headers that are available
// OptionStatusCode sets a custom status code on the OPTIONS requests.
// Default behaviour sets it to 200 to reflect best practices. This is option is not mandatory
// and can be used if you need a custom status code (i.e 204) or have a monitoring
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the piece about monitoring middleware - as per my other comment, there are more robust ways to get the real status code in middleware when logging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree we should keep this generic. I'm removing it.

@elithrar elithrar merged commit 7e0369f into gorilla:master Sep 14, 2018
@elithrar
Copy link
Contributor

Thanks @commit-master!

@commit-master commit-master deleted the fix-options-status-code branch September 14, 2018 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants