Skip to content

Commit

Permalink
feat: add support for string and Unit request and response types (#879)
Browse files Browse the repository at this point in the history
See #876
  • Loading branch information
wesbillman authored Feb 6, 2024
1 parent a5d45c9 commit 908cfcb
Show file tree
Hide file tree
Showing 9 changed files with 450 additions and 325 deletions.
10 changes: 8 additions & 2 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

body, err := ingress.ValidateAndExtractRequestBody(route, r, sch)
body, err := ingress.BuildRequestBody(route, r, sch)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
Expand Down Expand Up @@ -248,7 +248,13 @@ func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}

ingress.SetDefaultContentType(response.Headers)
verbResponse := verb.Response.(*schema.DataRef) //nolint:forcetypeassert
err = ingress.ValidateContentType(verbResponse, sch, response.Headers)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}

responseBody, err = ingress.ResponseBodyForVerb(sch, verb, response.Body, response.Headers)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand Down
Loading

0 comments on commit 908cfcb

Please sign in to comment.