Handler for azure sample calls super in different method

If FooHandler extends AzureSpringBootRequestHandler apparently
Azure cannot extract the generic types Foo and Bar.
This commit is contained in:
Dave Syer
2018-01-24 14:24:13 +00:00
parent 7604de3ca7
commit b0bddd3160
10 changed files with 111 additions and 82 deletions

View File

@@ -21,10 +21,10 @@ The Azure tooling needs to find some JSON configuration files to tell it how to
```
{
"scriptFile" : "../function-sample-azure-1.0.0.BUILD-SNAPSHOT-azure.jar",
"entryPoint" : "example.FooHandler.handleRequest",
"entryPoint" : "example.FooHandler.execute",
"bindings" : [ {
"type" : "httpTrigger",
"name" : "req",
"name" : "foo",
"direction" : "in",
"authLevel" : "anonymous",
"methods" : [ "get", "post" ]
@@ -59,13 +59,11 @@ You will need the `az` CLI app and some node.js fu (see https://docs.microsoft.c
----
$ az login
$ mvn azure-functions:deploy
On another terminal try this: curl https://<azure-function-url-from-the-log>/api/uppercase -d '{"value": "hello foobar!"}'
Please ensure that you use the right URL for the function above.
----
The input type for the function in the Azure sample is a Foo with a single property called "value". So you would need this to test it with something as below.
On another terminal try this: `curl https://<azure-function-url-from-the-log>/api/uppercase -d '{"value": "hello foobar!"}'`. Please ensure that you use the right URL for the function above. Alternatively you can test the function in the Azure Dashboard UI (click on the function name, go to the right hand side and click "Test" and to the bottom right, "Run").
The input type for the function in the Azure sample is a Foo with a single property called "value". So you need this to test it with something like below:
----
{

View File

@@ -29,7 +29,7 @@ import reactor.core.publisher.Flux;
*/
public class AzureSpringBootRequestHandler<I, O> extends AzureSpringFunctionInitializer {
public Object handleRequest(I foo, ExecutionContext context) {
public O handleRequest(I foo, ExecutionContext context) {
context.getLogger().info("Handler Java HTTP trigger processed a request.");
initialize(context);
@@ -49,15 +49,19 @@ public class AzureSpringBootRequestHandler<I, O> extends AzureSpringFunctionInit
return Flux.just(input);
}
private Object result(Object input, Flux<?> output) {
private O result(Object input, Flux<?> output) {
List<Object> result = new ArrayList<>();
for (Object value : output.toIterable()) {
result.add(convertOutput(value));
}
if (isSingleValue(input) && result.size() == 1) {
return result.get(0);
@SuppressWarnings("unchecked")
O value = (O) result.get(0);
return value;
}
return result;
@SuppressWarnings("unchecked")
O value = (O) result;
return value;
}
private boolean isSingleValue(Object input) {