apache / openwhisk-apigateway

Apache OpenWhisk API Gateway service for exposing actions as REST interfaces.
https://openwhisk.apache.org/
Apache License 2.0
64 stars 45 forks source link

Expose base path to the action #311

Open akrabat opened 6 years ago

akrabat commented 6 years ago

I'm trying to find a way to determine the fully qualified base URL that was used for my action so that I can create URLs in my payloads to other resources in my API.

e.g. if you set up as per https://github.com/apache/incubator-openwhisk/blob/master/docs/apigateway.md#exposing-multiple-web-actions then:

As it stands, we have:

My initial idea was to subtract __ow_path from __ow_headers, but it doesn't work as __ow_path is very different depending on if there's a placeholder in the path:

i.e. if you call the URL for /club/books/, then __ow_path is /, but if you call the URL for /club/books/12 the __ow_path is /club/books/12

Suggested solution:

Provide __ow_base_path which is equal to /club in this example.

ddragosd commented 6 years ago

Provide __ow_base_path which is equal to /club in this example.

I think we can also assume that when developers use swagger spec, that basePath would be /club ?

mhamann commented 6 years ago

I would agree that the basePath from the swagger is the right thing.