openfaas / templates

OpenFaaS Classic templates
https://www.openfaas.com
MIT License
276 stars 228 forks source link

Upgrade versions and used Handler interface #193

Open pmlopes opened 4 years ago

pmlopes commented 4 years ago

Signed-off-by: Paulo Lopes pmlopes@gmail.com

The template was using an old version of vert.x and the handler should not implement the BodyHandler interface as it does not mean that you will get the HTTP body parsed. This needs to be passed on the bootstrap project and implement the vert.x Handler functional interface.

As a benefit this makes the function code smaller.

Still the original template or this PR do not expose the router to the function as a setup step. This would be interesting to chain middleware. As an example we could process CORS, or security before the function is executed.

Also post processing is not possible, for example a catch all error handler.

alexellis commented 4 years ago

Hi @pmlopes thank you for this PR, please could you rebase?

jconlon commented 3 years ago

@pmlopes Like the idea of exposing the router. But Vert.x is now at 4.0.0. Are there reasons we dont want to use the latest 4.0.0?

pmlopes commented 3 years ago

@alexellis @jconlon This pr got lost on my side. Yes, we should upgrade it to 4.0.0. One of the improvements, application wize there should be almost to none code changes for the end user.

We could change the style from callback to future/promise style which improves readability and internally guarantees that the thread affinity is always correct as the future object will enforce it.