I currently face the issue, how to implement a function in golang, which allows me to parse a config file or similar to then process the information how a certain request to an API should be made.
Example
config:
myrequest:
headers:
X-Forwarded-For: abc
Authorization: Bearer $env_token
endpoint: https://myfancyendpoint.com/path/action.do
method: POST
...
I then want to parse this in golang and execute the request according to the specification of the user in the config file (and do some post processing with the response later on).
But is there a standardized format which I can use / import directly into golang or do I have to code configuration options for the whole HTTP RFC spec by myself?
E.g. some tools can export API requests as “curl” statements. This is – however – cumbersome to use as “format” for a request specification.
Is there a standardized format to store request information and a library to parse it in golang?
I want to be as flexible as possible to allow users to adapt to any (REST) APIs they want to consume with my tool.