Class LightLambdaExchange


  • public final class LightLambdaExchange
    extends Object
    Shared object among middleware threads containing information on the request/response event.
    • Constructor Detail

      • LightLambdaExchange

        public LightLambdaExchange​(com.amazonaws.services.lambda.runtime.Context context,
                                   Chain chain)
    • Method Detail

      • executeChain

        public void executeChain()
      • setInitialResponse

        public void setInitialResponse​(com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent response)
        Sets the response object of the exchange.
        Parameters:
        response - -
      • setInitialRequest

        public void setInitialRequest​(com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent request)
        Sets the request object of the exchange.
        Parameters:
        request - -
      • getResponse

        public com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent getResponse()
        Returns the response object or an exception object if there was a failure.
        Returns:
        - return formatted response event.
      • getContext

        public com.amazonaws.services.lambda.runtime.Context getContext()
      • getRequest

        public com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent getRequest()
      • getReadOnlyRequest

        public com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent getReadOnlyRequest()
      • getStatusCode

        public int getStatusCode()
      • getFinalizedRequest

        public com.amazonaws.services.lambda.runtime.events.APIGatewayProxyRequestEvent getFinalizedRequest​(boolean fromListener)
        Terminates the request portion of the exchange and invokes the exchangeRequestCompleteListeners. You cannot finalize a request that has already been finalized.
        Parameters:
        fromListener - - if the call is from a listener, do not invoke listeners again.
        Returns:
        - returns the complete and final request event.
      • getFinalizedResponse

        public com.amazonaws.services.lambda.runtime.events.APIGatewayProxyResponseEvent getFinalizedResponse​(boolean fromListener)
        Terminates the response portion of the exchange and invokes the exchangeResponseCompleteListeners. You cannot finalize a response that has already been finalized.
        Parameters:
        fromListener - - if the call is from a listener, do not invoke listeners again.
        Returns:
        - returns the complete and final response event.
      • updateExchangeStatus

        public void updateExchangeStatus​(com.networknt.status.Status status)
        Update the exchange. This happens automatically after each middleware execution, but it can be invoked manually by user logic.

        Once an exchange is marked as failed, no longer handle updates.

        Parameters:
        status - - status to update the exchange with.
      • hasFailedState

        public boolean hasFailedState()
        Check to see if the exchange has any error state at all.
        Returns:
        - returns true if the exchange has a failure state.
      • isRequestInProgress

        public boolean isRequestInProgress()
        Checks to see if the exchange is in the 'request in progress' state. The exchange is in the request state when the request chain is ready and has not finished executing.
        Returns:
        - returns true if the exchange is handing the request.
      • isRequestComplete

        public boolean isRequestComplete()
      • isResponseInProgress

        public boolean isResponseInProgress()
        Checks to see if the exchange is in the response in progress state. The exchange is in the response state when the request chain is complete, and the response chain is ready and has not finished executing.
        Returns:
        - return true if the exchange is handling the response.
      • isResponseComplete

        public boolean isResponseComplete()
        Checks to see if the exchange has the response portion complete.
        Returns:
        - true if the response is complete.
      • isExchangeComplete

        public boolean isExchangeComplete()
        Checks to see if the exchange is complete.
        Returns:
        - true if the exchange is complete.
      • getState

        public int getState()
        Returns:
        int state
      • getAttachment

        public Object getAttachment​(LightLambdaExchange.Attachable<?> attachable)
        Get attachment object for given key.
        Parameters:
        attachable - - middleware key
        Returns:
        - returns the object for the provided key. Can return null if it does not exist.