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

public class AzureHttpFunction extends AzureFunction
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 Details

    • httpHandler

      protected io.micronaut.servlet.http.ServletHttpHandler<com.microsoft.azure.functions.HttpRequestMessage<Optional<String>>,com.microsoft.azure.functions.HttpResponseMessage> 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 request
      executionContext - 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 method
      uri - The URI
      Returns:
      The builder
    • request

      public HttpRequestMessageBuilder<?> request(io.micronaut.http.HttpMethod method, String uri)
      Start a new request.
      Parameters:
      method - The method
      uri - The URI
      Returns:
      The builder