Hello,
I’d like to manage some variables included in the basepath and apply them into the target endpoint.
Taking as example this kind of API :
GET http://mydomain.com/v1/api/customers
GET http://mydomain.com/v1/api/customers/{id}
POST http://mydomain.com/v1/api/customers/{id}
GET http://mydomain.com/v1/api/customers/{id}/address
GET http://mydomain.com/v1/api/customers/{id}/address/{id}
GET http://mydomain.com/v1/api/customers/{id}/orders
GET http://mydomain.com/v1/api/customers/{id}/orders/{orderId}
Giving such results :
GET http://mydomain.com/v1/api/customers
→ http 206 (paginated responses, returning 10 first customers over many…)
→ {{“id”:“001”,“name”:“doe”,“firstname”:“john”}, {“id”:“002”,“name”:“cho”,“firstname”:“john”},
… , {“id”:“010”,“name”:“ten”,“firstname”:“john”}}
GET http://mydomain.com/v1/api/customers/001
→ http 200
→ {“id”:“001”,“name”:“doe”,“firstname”:“john”,“birthdate”:“01/01/1954”, etc…}
POST http://mydomain.com/v1/api/customers/{id}
→ http 200
→ customer created, blablabla
GET http://mydomain.com/v1/api/customers/001/address
→ http 200
→ {{“id”:“adr1”,“city”:“NY”,“zipcode”:“xxx”,“country”:“US”},
{“id”:“adr2”,“city”:“Los Angeles”,“zipcode”:“xxx”,“country”:“US”}}
PUT http://mydomain.com/v1/api/customers/001/address/adr1
→ http 200
→ adresse updated
etc…
I’m searching how can i add an API Proxies containing a regex, something like :
- basepath = /v1/api/customers/[d+]/address/[.*]
- extract two path variables to set in the target endpoint
- target endpoint = http://mydomain.com/v1/api/customers/{customer_id}/address/{address_id}
I guess there’s some tips to fill the request target endpoint, but how to create the API proxies with such basepath?
Should i create only one base path /v1/api/customers then manage all the different calls in the same API Proxy?