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
By walking the Router we are able to Get Routes' PathTemplates, QueriesTemplates, etc.
But we are not able(at least I haven't been) to get the body accepted by the request neither the possible responses' bodies. This could really come in handy when automating the writing of API Documentations as well as validating the requests received.
By adding the functions like BodyInput( ) and BodyOutput( ) to a Route, we'd be able to set Input/Output body parameters (add Headers as well?). Therefore, by adding a function GetBodyInput() and GetBodyOutput() it'd be possible to read them. To the output nevertheless, the question to be made is : do we only set the 200 status response or do we set a map with codes as keys?
Alternatives I've considered
As to the alternatives, I'm trying to create an struct containing the routes, the parameters and the outputs to gaether them all in one place, but it seems to me that I'd be quite usefull to have them set on the Route itself.
The text was updated successfully, but these errors were encountered:
By adding the functions like BodyInput( ) and BodyOutput( ) to a Route, we'd be able to set Input/Output body parameters (add Headers as well?)
@deBarrosS could you be a bit more specific what are you trying to say with an example?
For adding headers as a part of request or response you can use middleware. If you haven't checked it before I would request you to please take a look at the project: https://github.com/gorilla/handlers/tree/master
Description of the solution I'd like
By walking the Router we are able to Get Routes' PathTemplates, QueriesTemplates, etc.
But we are not able(at least I haven't been) to get the body accepted by the request neither the possible responses' bodies. This could really come in handy when automating the writing of API Documentations as well as validating the requests received.
By adding the functions like BodyInput( ) and BodyOutput( ) to a Route, we'd be able to set Input/Output body parameters (add Headers as well?). Therefore, by adding a function GetBodyInput() and GetBodyOutput() it'd be possible to read them. To the output nevertheless, the question to be made is : do we only set the 200 status response or do we set a map with codes as keys?
Alternatives I've considered
As to the alternatives, I'm trying to create an struct containing the routes, the parameters and the outputs to gaether them all in one place, but it seems to me that I'd be quite usefull to have them set on the Route itself.
The text was updated successfully, but these errors were encountered: