-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
add default response format for when the 'Accept' header is missing #2500
Conversation
Hmm, this didn't trigger a CI build. @therealgambo is there anything odd about this PR or your fork that would stop Travis from executing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! A few small notes. :)
kong/core/error_handlers.lua
Outdated
template = text_template | ||
content_type = TYPE_PLAIN | ||
elseif find(accept_header, TYPE_HTML, nil, true) then | ||
accept_header = singletons.configuration.response_format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I missing something, or is this missing an end
?
kong.conf.default
Outdated
@@ -178,6 +178,9 @@ | |||
# See http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_recursive | |||
# for a description of this directive. | |||
|
|||
#response_format = text/plain # The default response format to use when the | |||
# 'Accept' header is missing in the request |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would be nice here to have a note of the valid elements based on the defined enum. Also, this needs clarification on exactly when this is used (e.g. for Nginx error handling, and not always errors generated by Kong, by plugins, or by upstream services).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, a better name for this property would be something closer to the Nginx default_type
directive, and carrying more context, like error_default_type
maybe.
Updated with changes. @p0pr0ck5 , this covers any Nginx error response / Kong error that makes its way into the
As for the CI not being triggered, I'm unsure why its not doing its magic. |
lgtm, still needs to have travis run. not sure why the PR portion isn't executing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will now need some tests :) Thanks!
@thibaultcha tests added. Please let me know if I have missed something in them or if you would like any additional checks. |
This seems okay to me, ran the full test suite against it without problems. Should we target |
I'm fine with it going into either. |
kong.conf.default
Outdated
@@ -178,6 +178,10 @@ | |||
# See http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_recursive | |||
# for a description of this directive. | |||
|
|||
#error_default_type = text/plain # Default response format to use when the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Default MIME type" instead maybe?
kong.conf.default
Outdated
@@ -178,6 +178,10 @@ | |||
# See http://nginx.org/en/docs/http/ngx_http_realip_module.html#real_ip_recursive | |||
# for a description of this directive. | |||
|
|||
#error_default_type = text/plain # Default response format to use when the | |||
# 'Accept' header is missing and Nginx | |||
# is returning an error for the request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also document which values are accepted if they are validated via an enum
in the config loader.
@thibaultcha updated. lgtm |
Merged to master in b737179 with the appropriate changes. Thank you for your contribution! |
Summary
Implementation of #2332 providing a configurable default response type to be used when the
Accept
header is not present in the request and an unhandled error is being returned from Nginx / Kong.Full changelog
error_default_type
Kong configuration property.Issues resolved
Fix #2332