-
Notifications
You must be signed in to change notification settings - Fork 1k
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
middleware for content type and accept headers #14075
Conversation
api/server/middleware/middleware.go
Outdated
accepted := false | ||
acceptTypes := strings.Split(acceptHeader, ",") | ||
for _, acceptType := range acceptTypes { | ||
acceptType = strings.TrimSpace(acceptType) | ||
for _, serverAcceptedType := range serverAcceptedTypes { | ||
if strings.HasPrefix(acceptType, serverAcceptedType) { | ||
accepted = true | ||
break | ||
} | ||
} | ||
if accepted { | ||
break | ||
} | ||
} |
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.
We should follow https://datatracker.ietf.org/doc/html/rfc2616#section-14.1. I don't think we have to support all edge cases, but */*
and type "/" "*"
would be nice to have.
}, | ||
{ | ||
template: "/eth/v1/beacon/pool/attester_slashings", | ||
name: namespace + ".SubmitAttesterSlashing", | ||
handler: server.SubmitAttesterSlashing, | ||
methods: []string{http.MethodPost}, | ||
middleware: []mux.MiddlewareFunc{ |
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.
Missing accept header
}, | ||
{ | ||
template: "/eth/v1/beacon/states/{state_id}/validators", | ||
name: namespace + ".GetValidators", | ||
handler: server.GetValidators, | ||
methods: []string{http.MethodGet, http.MethodPost}, | ||
middleware: []mux.MiddlewareFunc{ |
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.
Missing accept header
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.
good catch
Co-authored-by: Radosław Kapka <[email protected]>
Co-authored-by: Radosław Kapka <[email protected]>
Co-authored-by: Radosław Kapka <[email protected]>
Co-authored-by: Radosław Kapka <[email protected]>
What type of PR is this?
Feature
What does this PR do? Why is it needed?
Adding middleware for handling content type and accept header checks.
Only impacts the beacon apis for now https://ethereum.github.io/beacon-APIs
Which issues(s) does this PR fix?
Fixes #14054
Other notes for review