Class AzureFunctionHttpTriggerHandler

java.lang.Object
io.inversion.azure.functions.AzureFunctionHttpTriggerHandler

public class AzureFunctionHttpTriggerHandler extends Object
Adapter to run an Inversion API as an Azure Function

TODO: multipart post is not yet supported but could be implemented: https://stackoverflow.com/questions/54473126/azure-functions-how-to-use-the-multiparthttpservletrequest-class-from-the-de

Similar functionality for AWS Lambdas is provided by io.inversion.lambda.AwsApiGatewayLambdaRequestStreamHandler

See Also:
Java Azure Functions
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected io.inversion.Api
     
    protected io.inversion.Engine
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected io.inversion.Api
    buildApi​(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext context)
    Optional subclass override hook to supply your own custom wired up Api.
    protected io.inversion.Engine
    buildEngine​(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext context)
    Optional subclass override hook to allow for advanced Engine configuration.
    protected com.microsoft.azure.functions.HttpResponseMessage
    buildHttpResponseMessage​(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> azReq, io.inversion.Request req, io.inversion.Response res)
     
    protected io.inversion.Request
    buildRequest​(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request)
     
    io.inversion.Api
     
    io.inversion.Engine
     
    com.microsoft.azure.functions.HttpResponseMessage
    run​(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext context)
     
    void
    setApi​(io.inversion.Api api)
     
    void
    setEngine​(io.inversion.Engine engine)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • engine

      protected io.inversion.Engine engine
    • api

      protected io.inversion.Api api
  • Constructor Details

    • AzureFunctionHttpTriggerHandler

      public AzureFunctionHttpTriggerHandler()
  • Method Details

    • run

      public com.microsoft.azure.functions.HttpResponseMessage run(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext context)
    • buildRequest

      protected io.inversion.Request buildRequest(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request)
    • buildHttpResponseMessage

      protected com.microsoft.azure.functions.HttpResponseMessage buildHttpResponseMessage(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> azReq, io.inversion.Request req, io.inversion.Response res) throws Exception
      Throws:
      Exception
    • buildEngine

      protected io.inversion.Engine buildEngine(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext context)
      Optional subclass override hook to allow for advanced Engine configuration.

      Simple embeddings can leave this alone. Complex embeddings can either set the engine via setEngine() or override this method to construct/configure as needed.

      This default implementation constructs an Engine with the supplied configProfile and adds api to it if api is not null.

      If api is null, it calls buildApi() which by default does nothing and is itself designed as an override hook.

      Parameters:
      request - the request to service
      context - the execution context
      Returns:
      an Engine with an Api already set if one was supplied otherwise an empty Engine that will be configured via via Confg/Configurator.
      See Also:
      buildApi(HttpRequestMessage, ExecutionContext)
    • buildApi

      protected io.inversion.Api buildApi(com.microsoft.azure.functions.HttpRequestMessage<Optional<String>> request, com.microsoft.azure.functions.ExecutionContext context)
      Optional subclass override hook to supply your own custom wired up Api.

      If you don't set your api via setApi() and you don't override buildApi() to supply an Api or otherwise wire your custom Api and Engine in an overridden buildEngine() method, you will need to define your Api in inversion.properties files for autowiring via Confg/Configurator.

      Parameters:
      request - the request to service
      context - the execution context
      Returns:
      null unless you override this method to construct an Api.
      See Also:
      buildEngine(com.microsoft.azure.functions.HttpRequestMessage<java.util.Optional<java.lang.String>>, com.microsoft.azure.functions.ExecutionContext)
    • getEngine

      public io.inversion.Engine getEngine()
    • setEngine

      public void setEngine(io.inversion.Engine engine)
    • getApi

      public io.inversion.Api getApi()
    • setApi

      public void setApi(io.inversion.Api api)