-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
docs/customizingyourgateway: add ?pretty example #954
docs/customizingyourgateway: add ?pretty example #954
Conversation
503e4af
to
fdd66ab
Compare
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 this! I think it's a great example of how easy the gateway is to configure.
docs/_docs/customizingyourgateway.md
Outdated
prettier := func(h http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
defer h.ServeHTTP(w, r) | ||
// if the "Accept" is set and NOT */* (sent by curl), keep it as-is |
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.
Why does this need special casing around */*
?
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.
It doesn't, in general. However, all folks I know (small sample) would end up using curl
on that endpoint, and curl
sends Accept: */*
by default. So, if we only check that an Accept
header was not provided, this will not work for curl
users.
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.
If figured, if you do not care (i.e. "accept */*
"), we might a well override your choice 😄
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.
What about removing this check altogether? Any Accept
header could be overridden when the pretty
parameter is present, maybe? What cases would that mess with?
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.
Oh you're right. In this example, that's surely fine. I was thinking better safe than sorry; but it's fine here.
fdd66ab
to
cd255b3
Compare
As discussed in slack. The code is rough, but should illustrate the point. Signed-off-by: Stephan Renatus <[email protected]>
cd255b3
to
b9a550b
Compare
Thanks for your contribution! |
As discussed in slack. The code is rough, but should illustrate the point. Signed-off-by: Stephan Renatus <[email protected]>
As discussed in slack. The code is rough, but should illustrate the
point.