You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Form encoding is a well structured, flat key-value pair interface. Much like application/json, we should be able to break out a case for a more ergonomic interface. I propose the following:
If you have more than one request body type, meaning more than one media
type, you will have a generic handler of this form:
AddPet(ctx context.Context, contentType string, body io.Reader)
If you have only a JSON request body, you will get:
AddPet(ctx context.Context, body NewPet)
If you have only a form url encoding request body, you will get:
AddPet(ctx context.Context, body NewPet)
If you have multiple request body types, which include a JSON or form encoded type you will get multiple functions. We've chosen to give the JSON version a shorter name, as we work with JSON and don't want to wear out our keyboards.
AddPet(ctx context.Context, body NewPet)
AddPetForm(ctx context.Context, body NewPet)
AddPetWithBody(ctx context.Context, contentType string, body io.Reader)
The text was updated successfully, but these errors were encountered:
I'm thinking the fix for this kind of issue is to allow the registering of unmarshal helper functions keyed off content-type, and we simply provide some pre-defined ones, but users are free to add their own.
That would be a very breaking API change, though. I'm going to start filing tasks for a V2 version of this library, where we will also get strict about semver for generated code.
Form encoding is a well structured, flat key-value pair interface. Much like
application/json
, we should be able to break out a case for a more ergonomic interface. I propose the following:If you have more than one request body type, meaning more than one media
type, you will have a generic handler of this form:
If you have only a JSON request body, you will get:
If you have only a form url encoding request body, you will get:
If you have multiple request body types, which include a JSON or form encoded type you will get multiple functions. We've chosen to give the JSON version a shorter name, as we work with JSON and don't want to wear out our keyboards.
The text was updated successfully, but these errors were encountered: