Closed keenranger closed 2 years ago
JSON body, as opposed to other parameters, can be a nested structure of arbitrary complexity. This makes custom field mapping more difficult, than flat map of other parameters.
From a technical perspective, json
body is decoded with a standard encoding/json
API that does not allow custom mapping interception. Other parameters are decoded with a custom library that allows custom mapping during decoding.
Also json
field tag does not have such a direct transport belonging as say query
, it is a transport-agnostic serialization tag and might be tolerated as a part of usecase/domain code.
These considerations led to a decision to support custom mapping only for non-json parameters. I think it is worth updating the docs to make this behavior limitations more visible.
Potentially, mapping handling could be changed to support json
fields, though I don't have a good idea on how useful that would be and what could be a strategy for a reliable implementation.
To be usecase independant of all transport protocol(e.g. grpc) I thought dividing transport layer and service layer is useful. But I also understand it isn't easy mapping json body. Thank you for answering and closing issue 👍
I want to seperate concerns between usecases and transport it, so I tried nethttp.RequestMapping() as shown on README.md. But I found it doesn't work for json body, and I started debug the package.
package rest has 6 const ParamIn
But in RequestMapping
only 5 of them are used without body for json input. I wonder is this intended.