Skip to content

Commit

Permalink
golangci-lint: change ifElseChain to switch.
Browse files Browse the repository at this point in the history
No other changes but this rewrite to switch.
  • Loading branch information
RatkoR committed Apr 8, 2023
1 parent f0aeb3a commit 7f8b3a6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions graphql/handler/transport/http_form_urlencoded.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@ func (h UrlEncodedForm) Do(w http.ResponseWriter, r *http.Request, exec graphql.
}

func (h UrlEncodedForm) parseBody(bodyString string) (*graphql.RawParams, error) {
if strings.Contains(bodyString, "\"query\":") {
switch {
case strings.Contains(bodyString, "\"query\":"):
// body is json
return h.parseJson(bodyString)

} else if strings.HasPrefix(bodyString, "query=%7B") {
case strings.HasPrefix(bodyString, "query=%7B"):
// body is urlencoded
return h.parseEncoded(bodyString)

} else {
default:
// body is plain text
params := &graphql.RawParams{}
params.Query = strings.TrimPrefix(bodyString, "query=")
Expand Down

0 comments on commit 7f8b3a6

Please sign in to comment.