Description
It seems the FunctionBean doesn't support the @Consumes
annotation. Doing some comparison work between a Function and a Controller, it appears the routing builder for FunctionBeans (AnnotatedFunctionRouteBuilder
) doesn't take into account any @Consumes
annotation that may have been supplied on the function method. Whereas the AnnotatedMethodRouteBuilder
which handles routing for Controllers does. Not sure if this is a defect or if there's a reason FunctionBeans don't support @Consumes
, however the documentation for @Consumes
does state it should be applicable to any component.
Task List
- Stacktrace (if present) provided
- Example that reproduces the problem uploaded to Github
- Full description of the issue provided (see below)
Steps to Reproduce
-
Create a FunctionBean with a single method (
apply
) in this case, which takes a single argument (a single 'name' parameter was being used in this case). Annotate the method with@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
. (see feedbackform function in provided github project) -
Send a request from a standard HTML form POST method with encoding type set to
application/x-www-form-urlencoded
, with the action going to your function endpoint. (see html form created in feedbackprocessor project in provided github project)
Expected Behaviour
As I understand the behaviour of @Consumes
, the AnnotatedFunctionRouteBuilder
should build the route with a list of acceptedMediaTypes
from the media types passed into the @Consumes
annotation set on the function method. This should then allow the function to accept incoming requests which have the encoding type of application/x-www-form-urlencoded
.
Actual Behaviour
The @Consumes
annotation appears to be ignored completely (can't see anything in the core code which does a look up on that annotation to set values on the route), and the default application/json
is used - which in this scenario causes an error due to the media type being used is; application/x-www-form-urlencoded
.
Error thrown is Matched route is not a supported media type: application/x-www-form-urlencoded
Environment Information
- Operating System: Windows 10
- Micronaut Version: 1.0.1
- JDK Version: 1.9
Example Application
-
feedbackform: contains simple code to build up a HTML form (which sends data to the processor function)
-
feedbackprocessor: should accept the incoming form data and process it (this fails with the above issue)