serverless-openwhisk icon indicating copy to clipboard operation
serverless-openwhisk copied to clipboard

Custom Domain Support

Open more-ron opened this issue 6 years ago • 1 comments

It's really inconvenient to keep manually setting the domain on IBM Cloud's web UI for this. Seems their API already supports being able to do this. It's just not the most intuitive way.

I've managed to be able to hack it up by:

  • manually getting the routes after deploy
ow.routes.list({basepath:`/${this.serverless.service.service}`}).then(routes => { ... });
  • picking the first one under routes.apis and slicing the swagger doc part.
let swagger = routes.apis[0].value.apidoc;
  • then deleting the routes again and putting them back using the modified swagger doc ( https://github.com/apache/incubator-openwhisk-client-js#add-route-swagger)
ow.routes.delete({basepath:`/${this.serverless.service.service}`});
swagger['x-ibm-configuration'].custom_domain = { domain: "yourdomain.com", subdomain: "api" };
ow.routes.create({ swagger: swagger });

If the plug-in generates the minimal swagger doc and uploads it instead of posting individual routes it could remove an api request per route. It could also pave the way for supporting custom domains.

I'm fairly new to node.js that's why there's no PR yet. Hoping somebody could add the support.

more-ron avatar Dec 14 '17 20:12 more-ron

Thanks for reporting this and the details that help me understand how to fix this.

I'll have a look over the next few weeks and see if I can submit a PR to resolve this.

jthomas avatar Dec 15 '17 16:12 jthomas