Package io.micronaut.azure.function.http
Class AzureHttpFunction
java.lang.Object
io.micronaut.azure.function.AzureFunction
io.micronaut.azure.function.http.AzureHttpFunction
- All Implemented Interfaces:
io.micronaut.context.ApplicationContextProvider
,Closeable
,AutoCloseable
This class can be used as a base class for Azure HTTP functions that wish to route requests
to classes annotated with
Controller
and the others annotations in the
io.micronaut.http.annotation
package.
To use this class you should define a new function that subclasses this class and then override the route(HttpRequestMessage, ExecutionContext)
(HttpRequestMessage, ExecutionContext)} method to customize the function mapping as per the Azure documentation. For example the following definition will route all requests to the function:
@FunctionName("myFunction")
@Override
public HttpResponseMessage invoke(
@HttpTrigger(name = "req",
route = "{*url}", // catch all route
authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage<Optional<String>> request,
ExecutionContext executionContext) {
}
- Since:
- 1.0.0
- Author:
- graemerocher
-
Field Summary
Modifier and TypeFieldDescriptionprotected io.micronaut.servlet.http.ServletHttpHandler<com.microsoft.azure.functions.HttpRequestMessage<Optional<String>>,
com.microsoft.azure.functions.HttpResponseMessage> Fields inherited from class io.micronaut.azure.function.AzureFunction
applicationContext, LOG
-
Constructor Summary
ModifierConstructorDescriptionprotected
Default constructor.AzureHttpFunction
(io.micronaut.context.ApplicationContextBuilder applicationContextBuilder) -
Method Summary
Modifier and TypeMethodDescriptionStart a new request.Start a new request.com.microsoft.azure.functions.HttpResponseMessage
route
(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext executionContext) Entry point for Azure functions written in Micronaut.Methods inherited from class io.micronaut.azure.function.AzureFunction
close, defaultApplicationContextBuilder, getApplicationContext, registerApplicationContextShutDownHook, startApplicationContext
-
Field Details
-
httpHandler
-
-
Constructor Details
-
AzureHttpFunction
protected AzureHttpFunction()Default constructor. -
AzureHttpFunction
public AzureHttpFunction(io.micronaut.context.ApplicationContextBuilder applicationContextBuilder) - Parameters:
applicationContextBuilder
- ApplicationContext Builder;
-
-
Method Details
-
route
public com.microsoft.azure.functions.HttpResponseMessage route(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext executionContext) Entry point for Azure functions written in Micronaut.- Parameters:
request
- The requestexecutionContext
- The execution context- Returns:
- The response message
-
request
public HttpRequestMessageBuilder<?> request(com.microsoft.azure.functions.HttpMethod method, String uri) Start a new request.- Parameters:
method
- The methoduri
- The URI- Returns:
- The builder
-
request
Start a new request.- Parameters:
method
- The methoduri
- The URI- Returns:
- The builder
-