Skip to content

Commit

Permalink
server/authorizer: inline readBody (open-policy-agent#6156)
Browse files Browse the repository at this point in the history
This was a waste of space.

Signed-off-by: Stephan Renatus <stephan@styra.com>
  • Loading branch information
srenatus authored Aug 14, 2023
1 parent 5d71b14 commit abb6cf2
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions server/authorizer/authorizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ func makeInput(r *http.Request) (*http.Request, interface{}, error) {
var rawBody []byte

if expectBody(r.Method, path) {
rawBody, err = readBody(r)
var err error
rawBody, err = io.ReadAll(r.Body)
if err != nil {
return r, nil, err
}
Expand Down Expand Up @@ -232,17 +233,6 @@ func expectYAML(r *http.Request) bool {
return strings.Contains(r.Header.Get("Content-Type"), "yaml")
}

func readBody(r *http.Request) ([]byte, error) {

bs, err := io.ReadAll(r.Body)

if err != nil {
return nil, err
}

return bs, nil
}

func parsePath(path string) ([]interface{}, error) {
if len(path) == 0 {
return []interface{}{}, nil
Expand Down

0 comments on commit abb6cf2

Please sign in to comment.