Class AwsApiGatewayLambdaRequestStreamHandler

  • All Implemented Interfaces:
    com.amazonaws.services.lambda.runtime.RequestStreamHandler

    public class AwsApiGatewayLambdaRequestStreamHandler
    extends java.lang.Object
    implements com.amazonaws.services.lambda.runtime.RequestStreamHandler
    Adapter to run an Inversion API as an AWS Lambda behind an ApiGateway
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected io.inversion.Api api  
      protected io.inversion.Engine engine  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected io.inversion.Api buildApi​(io.inversion.Engine engine)
      Optional subclass override hook to supply your own custom wired up Api.
      protected io.inversion.Engine buildEngine​(java.lang.String configProfile, java.lang.String servletPath)
      Optional subclass override hook to allow for advanced Engine configuration.
      void debug​(java.lang.String msg)  
      io.inversion.Api getApi()  
      io.inversion.Engine getEngine()  
      void handleRequest​(java.io.InputStream inputStream, java.io.OutputStream outputStream, com.amazonaws.services.lambda.runtime.Context context)  
      boolean isDebug()  
      void setApi​(io.inversion.Api api)  
      void setDebug​(boolean debug)  
      void setEngine​(io.inversion.Engine engine)  
      protected void writeResponse​(io.inversion.Response res, java.io.OutputStream outputStream)  
      • Methods inherited from class java.lang.Object

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

      • engine

        protected io.inversion.Engine engine
      • api

        protected io.inversion.Api api
    • Constructor Detail

      • AwsApiGatewayLambdaRequestStreamHandler

        public AwsApiGatewayLambdaRequestStreamHandler()
    • Method Detail

      • handleRequest

        public void handleRequest​(java.io.InputStream inputStream,
                                  java.io.OutputStream outputStream,
                                  com.amazonaws.services.lambda.runtime.Context context)
                           throws java.io.IOException
        Specified by:
        handleRequest in interface com.amazonaws.services.lambda.runtime.RequestStreamHandler
        Throws:
        java.io.IOException
      • buildEngine

        protected io.inversion.Engine buildEngine​(java.lang.String configProfile,
                                                  java.lang.String servletPath)
        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:
        configProfile - the configuration runtime profile
        servletPath - the servlet path
        Returns:
        an Engine with an Api already set if one was supplied otherwise an empty Engine that will be configured via via Config/Wirer.
        See Also:
        buildApi(io.inversion.Engine)
      • buildApi

        protected io.inversion.Api buildApi​(io.inversion.Engine engine)
        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 Config/Wirer.

        Parameters:
        engine - the engine that will host the Api
        Returns:
        null unless you override this method to construct an Api.
        See Also:
        buildEngine(java.lang.String, java.lang.String)
      • writeResponse

        protected void writeResponse​(io.inversion.Response res,
                                     java.io.OutputStream outputStream)
                              throws java.io.IOException
        Throws:
        java.io.IOException
      • debug

        public void debug​(java.lang.String msg)
      • isDebug

        public boolean isDebug()
      • setDebug

        public void setDebug​(boolean debug)
      • 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)