Class ContainerConfig

java.lang.Object
com.amazonaws.serverless.proxy.model.ContainerConfig

public class ContainerConfig extends Object
Configuration parameters for the framework
  • Field Details

  • Constructor Details

    • ContainerConfig

      public ContainerConfig()
  • Method Details

    • defaultConfig

      public static ContainerConfig defaultConfig()
    • getServiceBasePath

      public String getServiceBasePath()
      Returns the base path configured in the container. This configuration variable is used in conjuction with setStripBasePath(boolean) to route the request. When requesting the context path from an HttpServletRequest: AwsProxyHttpServletRequest.getContextPath() this base path is added to the context even though it was initially stripped for the purpose of routing the request. We decided to add it to the context to address GitHub issue #84 and allow framework's link builders to it.
      Returns:
      The base path configured for the container
    • setServiceBasePath

      public void setServiceBasePath(String serviceBasePath)
      Configures a base path that can be stripped from the request path before passing it to the framework-specific implementation. This can be used to remove API Gateway's base path mappings from the request.
      Parameters:
      serviceBasePath - The base path mapping to be removed.
    • isStripBasePath

      public boolean isStripBasePath()
    • setStripBasePath

      public void setStripBasePath(boolean stripBasePath)
      Whether this framework should strip the base path mapping specified with the setServiceBasePath(String) method from a request before passing it to the framework-specific implementations
      Parameters:
      stripBasePath -
    • getUriEncoding

      public String getUriEncoding()
    • setUriEncoding

      public void setUriEncoding(String uriEncoding)
      Sets the charset used to URLEncode and Decode request paths.
      Parameters:
      uriEncoding - The charset. By default this is set to UTF-8
    • isConsolidateSetCookieHeaders

      public boolean isConsolidateSetCookieHeaders()
    • setConsolidateSetCookieHeaders

      public void setConsolidateSetCookieHeaders(boolean consolidateSetCookieHeaders)
      Tells the library to consolidate multiple Set-Cookie headers into a single Set-Cookie header with multiple, comma-separated values. This is allowed by the RFC 2109 (https://tools.ietf.org/html/rfc2109). However, since not all clients support this, we consider it optional. When this value is set to true the framework will consolidate all Set-Cookie headers into a single header, when it's set to false, the framework will only return the first Set-Cookie header specified in a response. Because API Gateway needs header keys to be unique, we give an option to configure this.
      Parameters:
      consolidateSetCookieHeaders - Whether to consolidate the cookie headers or not.
    • isUseStageAsServletContext

      public boolean isUseStageAsServletContext()
      Tells whether the stage name passed in the request should be added to the context path: AwsProxyHttpServletRequest.getContextPath().
      Returns:
      true if the stage will be included in the context path, false otherwise.
    • setUseStageAsServletContext

      public void setUseStageAsServletContext(boolean useStageAsServletContext)
      Sets whether the API Gateway stage name should be included in the servlet context path.
      Parameters:
      useStageAsServletContext - true if you want the stage to appear as the root of the context path, false otherwise.
    • getValidFilePaths

      public List<String> getValidFilePaths()
      Returns the list of file paths that the servlet accepts read/write requests to
      Returns:
      A List of file paths. By default this is set to /tmp and /var/task
    • setValidFilePaths

      public void setValidFilePaths(List<String> validFilePaths)
      Sets a list of valid file paths for the servlet to read/write from.
      Parameters:
      validFilePaths - A populated list of base paths
    • addValidFilePath

      public void addValidFilePath(String filePath)
      Adds a new base path to the list of allowed paths.
      Parameters:
      filePath - The base path
    • addCustomDomain

      public void addCustomDomain(String name)
      Adds a new custom domain name to the list of allowed domains
      Parameters:
      name - The new custom domain name, excluding the scheme ("https") and port
    • getCustomDomainNames

      public List<String> getCustomDomainNames()
      Returns the list of custom domain names enabled for the application
      Returns:
      The configured custom domain names
    • enableLocalhost

      public void enableLocalhost()
      Enables localhost custom domain name for testing. This setting should be used only in local with SAM local
    • isQueryStringCaseSensitive

      public boolean isQueryStringCaseSensitive()
      Whether query string parameters in the request should be case sensitive or not. By default this is set to false for backward compatibility.
      Returns:
      true if the parameter matching algorithm is case sensitive
    • setQueryStringCaseSensitive

      public void setQueryStringCaseSensitive(boolean queryStringCaseSensitive)
      Sets whether query string parameter names should be treated as case sensitive. The default value of this option is false for backward compatibility.
      Parameters:
      queryStringCaseSensitive - Tells the framework to treat query string parameter names as case sensitive
    • addBinaryContentTypes

      public void addBinaryContentTypes(String... contentTypes)
      Configure specified content type(s) as binary
      Parameters:
      contentTypes - list of exact content types that will be considered as binary
    • isBinaryContentType

      public boolean isBinaryContentType(String contentType)
      Determine if specified content type has been configured as binary
      Parameters:
      contentType - content type to query
      Returns:
    • getDefaultContentCharset

      public String getDefaultContentCharset()
      Returns the name of the default charset appended to the Content-Type header if no charset is specified by the request. The default value of this is ISO-8859-1.
      Returns:
      The name of the default charset for the Content-Type header
    • setDefaultContentCharset

      public void setDefaultContentCharset(String defaultContentCharset)
      Sets the default charset value for the Content-Type header if no charset is specified with a request. The default value of this is ISO-8859-1. If a request specifies a Content-Type header without a charset property, the value of this field is automatically appended to the header.
      Parameters:
      defaultContentCharset - The name of the charset for the content type header.
    • getInitializationTimeout

      public int getInitializationTimeout()
      Returns the maximum amount of time (in milliseconds) set for the initialization time. See documentation on the setInitializationTimeout(int) for additional details.
      Returns:
      The max time allocated for initialization
    • setInitializationTimeout

      public void setInitializationTimeout(int initializationTimeout)
      Sets the initialization timeout. When using an async InitializationWrapper the underlying framework is initialized in a separate thread. Serverless Java Container will wait for the maximum time available during AWS Lambda's init step (~10 seconds) and then return control to the main thread. In the meanwhile, the initialization process of the underlying framework can continue in a separate thread. AWS Lambda will then call the handler class to handle an event. This timeout is the maximum amount of time Serverless Java Container framework will wait for the underlying framework to initialize before returning an error. By default, this is set to 10 seconds.
      Parameters:
      initializationTimeout - The maximum amount of time to wait for the underlying framework initialization after an event is received in milliseconds.
    • isDisableExceptionMapper

      public boolean isDisableExceptionMapper()
      Whether the framework will run exception thrown by the application through the implementation of ExceptionHandler. When this parameter is set to false the Lambda container handler object lets the Exception propagate upwards to the Lambda handler class.
      Returns:
      true if exception mapping is disabled, false otherwise.
    • setDisableExceptionMapper

      public void setDisableExceptionMapper(boolean disable)
      This configuration parameter tells the container whether it should skip exception mapping and simply let any Exception thrown by the underlying application bubble up to the Lambda handler class.
      Parameters:
      disable - Set this value to true to disable exception mapping, false otherwise.