Expected Behaviour
When building a function using the java11-vert-x template, i should be able to access the HTTP request body from the RoutingContext object.
Current Behaviour
Recovering body using Vertx API e.g routingContext.getBody() raises a NullPointerException because the routingContext object isn't populated with the HTTP request body.
Possible Solution
Adding a BodyHandler object to the Vertx router handlers will populate the RoutingContext and fix the issue.
Steps to Reproduce (for bugs)
link to a live example: https://github.com/p-fortier/openfaas-java11-showcase
- Create a function using
java11-vert-x template
- Access the body within the generated handler
src/main/java/com/openfaas/function/Handler.java. e.g using System.out.println(routingContext.getBody());
- Observe the raised exception when invoking the function. HTTP 500 and function logs
3'. edit: no exception raised in this scenario, no http 500. logs inside showcase shows empty context 2021/04/06 08:21:48 stdout: null
Context
I was building an OpenFaaS workflow using faas-flow and java11-vert-x template.
My goal was to build a workflow processing data from function to function.
This issue prevented me from recovering the HTTP request body in any function.
Your Environment
Not relevant.
Expected Behaviour
When building a function using the
java11-vert-xtemplate, i should be able to access the HTTP request body from theRoutingContextobject.Current Behaviour
Recovering body using Vertx API e.g
routingContext.getBody()raises aNullPointerExceptionbecause the routingContext object isn't populated with the HTTP request body.Possible Solution
Adding a
BodyHandlerobject to the Vertx router handlers will populate theRoutingContextand fix the issue.Steps to Reproduce (for bugs)
link to a live example: https://github.com/p-fortier/openfaas-java11-showcase
java11-vert-xtemplatesrc/main/java/com/openfaas/function/Handler.java. e.g usingSystem.out.println(routingContext.getBody());3'. edit: no exception raised in this scenario, no http 500. logs inside showcase shows empty context
2021/04/06 08:21:48 stdout: nullContext
I was building an OpenFaaS workflow using faas-flow and
java11-vert-xtemplate.My goal was to build a workflow processing data from function to function.
This issue prevented me from recovering the HTTP request body in any function.
Your Environment
Not relevant.