RequestErrorHandlerFunc unused in net/http (strict) server? #1991
-
|
I'm starting with and extending an example of a minimal spec and generation of server code with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Please have a look at the generated code, as it heavily depends on the path you're accessing. Taken the common PetStore specification, there's only one point where this callback is added: // CreatePets operation middleware
func (sh *strictHandler) CreatePets(w http.ResponseWriter, r *http.Request) {
var request CreatePetsRequestObject
var body CreatePetsJSONRequestBody
if err := json.NewDecoder(r.Body).Decode(&body); err != nil {
sh.options.RequestErrorHandlerFunc(w, r, fmt.Errorf("can't decode JSON body: %w", err))
return
}
...So the only way to access this error handler here is by sending a request body that can't be decoded to JSON; like empty, plain text, XML... |
Beta Was this translation helpful? Give feedback.
Please have a look at the generated code, as it heavily depends on the path you're accessing.
Taken the common PetStore specification, there's only one point where this callback is added:
So the only way to access this error handler here is by sending a request body that can't be decoded to JSON; like empty, plain text, XML...