Closed kobynet closed 5 years ago
Hi, can you give a bit more info on what you're trying to achieve?
Why are you looking at this specific OpenFaaS Template? We will need more context.
Cheers,
Alex
Thanks @alexellis for your fast comment.
I am trying to migrate one of our restful api services into openfaas. Part of what i am trying to achieve is backward compatibility, so if for example i have a resource "user", i would like to have endpoint http://some-host.com:8080/api/user which will manage the user resource, hence would be able to deal with GET/POST/PUT/DELETE (sometimes also patch) methods.
That being said, i have few solutions in mind, and would like to see if anyone went in my path before or i am "inventing the wheel" here(this sounds to me like a very common scenario to migrate rest api to serverless architecture)
Solution 1 (no backward compatibility ): Since a function is invoked only with POST, there should be some sort of "X-Http-method-override" header added to the call, and in express template we need to be able to handle such header accordingly (for example using https://github.com/expressjs/method-override - this kind of solution requires designing the rest service as a single function with a switch-case handlers for each method. backward compatibility not kept in this case since we need to make POST calls + x-http-method-override header
Solution 2 (Backward compatible): Using kong Serverless plugin and implementing pre-function and post-function plugin to make a call to the desired function (delete user for example). this way kong is acting as "smart reverse proxy" and we can have different function for each http method (create/delete/update/query without switch-case). This couples the solution to kong and not be suitable for everyone and also requires writing kong plugin in lua.
Hi @kobynet
Let's move the discussion on faas#214 as this is related.
For the path changes there is an issue raised as well: faas#716
In this endpoint - http://some-host.com:8080/api/user - is user
intended to be a function?
A related part of the implementation is in gateway/server.go#L144 and any changes can be considered in the same context.
Ivana
I believe these are supported. Closing the issue. Feel free to keep commenting.
I see in the express server that only get/post is supported, is there a reason for that?