The resources should be registered in the file resources/resources.json
in the following format:
{
"swapi-people": {
"url":"https://swapi.dev/api/people/:personId/",
"method":"GET"
}
}
The queries should be registered in the file queries/queries.json
in the following format:
{
"swapi-people": {
"resource": "swapi-people", // configured resource
"queryParams": [ // query params to add to request
{
"name": "format",
"type": "constant",
"value": "json"
},
{
"name": "resourceQueryParamKey",
"type": "querystring", // query param forwarded from request
"value": "receivedQueryParam"
}
],
"pathParams": [ // path params to add to request
{
"name": "personId",
"type": "querystring", // path param from query string
"value": "otherReceivedQueryParam"
}
],
"headers": [ // headers to add to request
{
"name": "Authorization",
"type": "constant",
"value": "Bearer 1234"
}
],
"returns": ["name"] // fields to return from response
}
}
Params can be of type constant
, querystring
, or header
.
go run cmd/main.go
curl -X GET "http://localhost:8080/swapi-people?receivedQueryParam=aValue&otherReceivedQueryParam=1"