Class ApiGatewayServletRequest<T,REQ,RES>

java.lang.Object
io.micronaut.function.aws.proxy.ApiGatewayServletRequest<T,REQ,RES>
Type Parameters:
T - The body type
REQ - The request event type
RES - The response event type
All Implemented Interfaces:
io.micronaut.core.attr.AttributeHolder, io.micronaut.core.attr.MutableAttributeHolder, io.micronaut.core.convert.ConversionServiceAware, io.micronaut.http.FullHttpRequest<T>, io.micronaut.http.HttpMessage<T>, io.micronaut.http.HttpRequest<T>, io.micronaut.http.MutableHttpMessage<T>, io.micronaut.http.MutableHttpRequest<T>, io.micronaut.http.ServerHttpRequest<T>, io.micronaut.servlet.http.MutableServletHttpRequest<REQ,T>, io.micronaut.servlet.http.ParsedBodyHolder<T>, io.micronaut.servlet.http.ServletExchange<REQ,RES>, io.micronaut.servlet.http.ServletHttpRequest<REQ,T>
Direct Known Subclasses:
ApiGatewayProxyServletRequest, APIGatewayV2HTTPEventServletRequest, ApplicationLoadBalancerServletRequest

@Internal public abstract class ApiGatewayServletRequest<T,REQ,RES> extends Object implements io.micronaut.servlet.http.MutableServletHttpRequest<REQ,T>, io.micronaut.servlet.http.ServletExchange<REQ,RES>, io.micronaut.http.FullHttpRequest<T>, io.micronaut.servlet.http.ParsedBodyHolder<T>, io.micronaut.http.ServerHttpRequest<T>
Base class for all the versions of the Gateway events.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
     

    Nested classes/interfaces inherited from interface io.micronaut.servlet.http.ServletHttpRequest

    io.micronaut.servlet.http.ServletHttpRequest.AsyncExecution, io.micronaut.servlet.http.ServletHttpRequest.AsyncExecutionCallback
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected io.micronaut.core.convert.ConversionService
     
    protected final REQ
     

    Fields inherited from interface io.micronaut.http.HttpRequest

    SCHEME_HTTP, SCHEME_HTTPS
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ApiGatewayServletRequest(io.micronaut.core.convert.ConversionService conversionService, REQ request, URI uri, io.micronaut.http.HttpMethod httpMethod, org.slf4j.Logger log, io.micronaut.servlet.http.BodyBuilder bodyBuilder)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <B> io.micronaut.http.MutableHttpRequest<B>
    body(B body)
     
    @Nullable io.micronaut.core.execution.ExecutionFlow<io.micronaut.core.io.buffer.ByteBuffer<?>>
     
    protected static URI
    buildUri(@Nullable String path, @Nullable Map<String,String> queryParameters, @Nullable Map<String,List<String>> multiQueryParameters)
    Given a path and the query params from the event, build a URI.
    @NonNull io.micronaut.http.body.ByteBody
     
    @Nullable io.micronaut.core.io.buffer.ByteBuffer<?>
     
    io.micronaut.http.MutableHttpRequest<T>
    cookie(io.micronaut.http.cookie.Cookie cookie)
     
    io.micronaut.core.convert.value.MutableConvertibleValues<Object>
     
    @NonNull Optional<T>
     
    <B> @NonNull Optional<B>
    getBody(io.micronaut.core.type.Argument<B> arg)
     
    abstract byte[]
     
    protected byte[]
    getBodyBytes(@NonNull Supplier<String> bodySupplier, @NonNull BooleanSupplier base64EncodedSupplier)
     
    @NonNull io.micronaut.http.cookie.Cookies
     
    protected @NonNull io.micronaut.http.MutableHttpHeaders
    getHeaders(@NonNull Supplier<Map<String,String>> singleHeaders, @NonNull Supplier<Map<String,List<String>>> multiValueHeaders)
     
     
    io.micronaut.http.HttpMethod
     
     
    protected @NonNull io.micronaut.http.MutableHttpParameters
    getParameters(@NonNull Supplier<Map<String,String>> queryStringParametersSupplier, @NonNull Supplier<Map<String,List<String>>> multiQueryStringParametersSupplier)
     
    getParametersFromBody(Map<String,String> queryStringParameters)
    Parse the parameters from the body.
     
    io.micronaut.servlet.http.ServletHttpRequest<REQ,? super Object>
     
     
    protected boolean
    isFormSubmission(io.micronaut.http.MediaType contentType)
     
    protected static io.micronaut.http.HttpMethod
    parseMethod(Supplier<String> httpMethodConsumer)
     
    void
    setConversionService(io.micronaut.core.convert.ConversionService conversionService)
     
    void
     
    protected static @NonNull List<String>
     
    protected static @NonNull Map<String,List<String>>
     
    io.micronaut.http.MutableHttpRequest<T>
    uri(URI uri)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface io.micronaut.core.attr.AttributeHolder

    getAttribute, getAttribute

    Methods inherited from interface io.micronaut.http.FullHttpRequest

    isFull

    Methods inherited from interface io.micronaut.http.HttpMessage

    getBody, getBody, getBodyWriter, getCharacterEncoding, getContentLength, getContentType

    Methods inherited from interface io.micronaut.http.HttpRequest

    accept, getCertificate, getHttpVersion, getLocale, getMethodName, getOrigin, getPath, getRemoteAddress, getServerAddress, getServerName, getSslSession, getUserPrincipal, getUserPrincipal, isSecure, mutate, setAttribute

    Methods inherited from interface io.micronaut.core.attr.MutableAttributeHolder

    removeAttribute

    Methods inherited from interface io.micronaut.http.MutableHttpMessage

    bodyWriter

    Methods inherited from interface io.micronaut.http.MutableHttpRequest

    accept, accept, basicAuth, bearerAuth, contentEncoding, contentLength, contentType, contentType, cookies, getHeaders, getParameters, header, headers, headers, uri

    Methods inherited from interface io.micronaut.servlet.http.ServletExchange

    getResponse

    Methods inherited from interface io.micronaut.servlet.http.ServletHttpRequest

    executeAsync, getContextPath, isAsyncSupported
  • Field Details

    • conversionService

      protected io.micronaut.core.convert.ConversionService conversionService
    • requestEvent

      protected final REQ requestEvent
  • Constructor Details

    • ApiGatewayServletRequest

      protected ApiGatewayServletRequest(io.micronaut.core.convert.ConversionService conversionService, REQ request, URI uri, io.micronaut.http.HttpMethod httpMethod, org.slf4j.Logger log, io.micronaut.servlet.http.BodyBuilder bodyBuilder)
  • Method Details

    • byteBody

      @NonNull public @NonNull io.micronaut.http.body.ByteBody byteBody()
      Specified by:
      byteBody in interface io.micronaut.http.ServerHttpRequest<T>
    • getBodyBytes

      public abstract byte[] getBodyBytes() throws ApiGatewayServletRequest.EmptyBodyException
      Throws:
      ApiGatewayServletRequest.EmptyBodyException
    • buildUri

      protected static URI buildUri(@Nullable @Nullable String path, @Nullable @Nullable Map<String,String> queryParameters, @Nullable @Nullable Map<String,List<String>> multiQueryParameters)
      Given a path and the query params from the event, build a URI.
      Parameters:
      path - the request path
      queryParameters - the query parameters from the event
      multiQueryParameters - the multi-value query parameters from the event
      Returns:
      the URI
      Since:
      4.0.3
    • parseMethod

      protected static io.micronaut.http.HttpMethod parseMethod(Supplier<String> httpMethodConsumer)
    • getInputStream

      public InputStream getInputStream() throws IOException
      Specified by:
      getInputStream in interface io.micronaut.servlet.http.ServletHttpRequest<T,REQ>
      Throws:
      IOException
    • getRequest

      public io.micronaut.servlet.http.ServletHttpRequest<REQ,? super Object> getRequest()
      Specified by:
      getRequest in interface io.micronaut.servlet.http.ServletExchange<T,REQ>
    • getReader

      public BufferedReader getReader() throws IOException
      Specified by:
      getReader in interface io.micronaut.servlet.http.ServletHttpRequest<T,REQ>
      Throws:
      IOException
    • getNativeRequest

      public REQ getNativeRequest()
      Specified by:
      getNativeRequest in interface io.micronaut.servlet.http.ServletHttpRequest<T,REQ>
    • getMethod

      public io.micronaut.http.HttpMethod getMethod()
      Specified by:
      getMethod in interface io.micronaut.http.HttpRequest<T>
    • getUri

      public URI getUri()
      Specified by:
      getUri in interface io.micronaut.http.HttpRequest<T>
    • getCookies

      @NonNull public @NonNull io.micronaut.http.cookie.Cookies getCookies()
      Specified by:
      getCookies in interface io.micronaut.http.HttpRequest<T>
    • getAttributes

      public io.micronaut.core.convert.value.MutableConvertibleValues<Object> getAttributes()
      Specified by:
      getAttributes in interface io.micronaut.core.attr.AttributeHolder
      Specified by:
      getAttributes in interface io.micronaut.http.HttpMessage<T>
      Specified by:
      getAttributes in interface io.micronaut.core.attr.MutableAttributeHolder
    • getBody

      @NonNull public @NonNull Optional<T> getBody()
      Specified by:
      getBody in interface io.micronaut.http.HttpMessage<T>
    • getBody

      @NonNull public <B> @NonNull Optional<B> getBody(io.micronaut.core.type.Argument<B> arg)
      Specified by:
      getBody in interface io.micronaut.http.HttpMessage<T>
    • isFormSubmission

      protected boolean isFormSubmission(io.micronaut.http.MediaType contentType)
      Parameters:
      contentType - Content Type
      Returns:
      returns true if the content type is either application/x-www-form-urlencoded or multipart/form-data
    • cookie

      public io.micronaut.http.MutableHttpRequest<T> cookie(io.micronaut.http.cookie.Cookie cookie)
      Specified by:
      cookie in interface io.micronaut.http.MutableHttpRequest<T>
    • uri

      public io.micronaut.http.MutableHttpRequest<T> uri(URI uri)
      Specified by:
      uri in interface io.micronaut.http.MutableHttpRequest<T>
    • body

      public <B> io.micronaut.http.MutableHttpRequest<B> body(B body)
      Specified by:
      body in interface io.micronaut.http.MutableHttpMessage<T>
      Specified by:
      body in interface io.micronaut.http.MutableHttpRequest<T>
    • getParametersFromBody

      protected MapListOfStringAndMapStringMutableHttpParameters getParametersFromBody(Map<String,String> queryStringParameters)
      Parse the parameters from the body.
      Parameters:
      queryStringParameters - Any query string parameters
      Returns:
      The parameters
    • setConversionService

      public void setConversionService(io.micronaut.core.convert.ConversionService conversionService)
      Specified by:
      setConversionService in interface io.micronaut.core.convert.ConversionServiceAware
    • setParsedBody

      public void setParsedBody(T body)
      Specified by:
      setParsedBody in interface io.micronaut.servlet.http.ParsedBodyHolder<T>
    • contents

      @Nullable public @Nullable io.micronaut.core.io.buffer.ByteBuffer<?> contents()
      Specified by:
      contents in interface io.micronaut.http.FullHttpRequest<T>
    • bufferContents

      @Nullable public @Nullable io.micronaut.core.execution.ExecutionFlow<io.micronaut.core.io.buffer.ByteBuffer<?>> bufferContents()
      Specified by:
      bufferContents in interface io.micronaut.http.FullHttpRequest<T>
    • getBodyBytes

      protected byte[] getBodyBytes(@NonNull @NonNull Supplier<String> bodySupplier, @NonNull @NonNull BooleanSupplier base64EncodedSupplier) throws ApiGatewayServletRequest.EmptyBodyException
      Parameters:
      bodySupplier - HTTP Request's Body Supplier
      base64EncodedSupplier - Whether the body is Base 64 encoded
      Returns:
      body bytes
      Throws:
      IOException - if the body is empty
      ApiGatewayServletRequest.EmptyBodyException
    • splitCommaSeparatedValue

      @NonNull protected static @NonNull List<String> splitCommaSeparatedValue(@Nullable @Nullable String value)
    • transformCommaSeparatedValue

      @NonNull protected static @NonNull Map<String,List<String>> transformCommaSeparatedValue(@Nullable @Nullable Map<String,String> input)
    • getParameters

      @NonNull protected @NonNull io.micronaut.http.MutableHttpParameters getParameters(@NonNull @NonNull Supplier<Map<String,String>> queryStringParametersSupplier, @NonNull @NonNull Supplier<Map<String,List<String>>> multiQueryStringParametersSupplier)
      Parameters:
      queryStringParametersSupplier - Query String parameters as a map with key string and value string
      multiQueryStringParametersSupplier - Query String parameters as a map with key string and value list of strings
      Returns:
      Mutable HTTP parameters
    • getHeaders

      @NonNull protected @NonNull io.micronaut.http.MutableHttpHeaders getHeaders(@NonNull @NonNull Supplier<Map<String,String>> singleHeaders, @NonNull @NonNull Supplier<Map<String,List<String>>> multiValueHeaders)
      Parameters:
      singleHeaders - Single value headers
      multiValueHeaders - Multi-value headers
      Returns:
      The combined mutable headers