-
Notifications
You must be signed in to change notification settings - Fork 213
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
Endpoint properly handles Accept header #36
Conversation
499a84f
to
c466bd0
Compare
c466bd0
to
aa2c4c5
Compare
cc @liggitt |
pkg/handler/handler.go
Outdated
return | ||
for _, clause := range clauses { | ||
for _, accepts := range accepted { | ||
if clause.Type == accepts.Type && clause.SubType == accepts.SubType || |
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.
nit, might be more readable unnested like this:
if clause.Type != accepts.Type && clause.Type != "*" {
continue
}
if clause.SubType != accepts.SubType && clause.SubType != "*" {
continue
}
data, etag, lastModified := accepts.GetDataAndETag()
w.Header().Set("Etag", etag)
// ServeContent will take care of caching using eTag.
http.ServeContent(w, r, servePath, lastModified, bytes.NewReader(data))
return
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.
updated
just noticed there are no tests in this package... probably worthwhile to test here before doing a vendor cycle into kube |
aa2c4c5
to
ab64a9b
Compare
use goautoneg.ParseAccept to sort Accept header
ab64a9b
to
35550e9
Compare
@liggitt I've added the test for |
code change LGTM |
@liggitt I agree, we need to port some of the main repo tools to this repo or develop a set of generic tool from them for any repo like this. |
this code looks good to me too. |
…ame patterns Signed-off-by: James Lamb <[email protected]>
Fixes kubernetes#36 Hostname matching doesn't conform to modern hostname patterns
Sort Accept header with q parameter
NOTE: I manually changed
Godep.json
.goautoneg
is used in kubernetes already.