Class ContainerConfig
java.lang.Object
com.amazonaws.serverless.proxy.model.ContainerConfig
Configuration parameters for the framework
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBinaryContentTypes(String... contentTypes) Configure specified content type(s) as binaryvoidaddCustomDomain(String name) Adds a new custom domain name to the list of allowed domainsvoidaddValidFilePath(String filePath) Adds a new base path to the list of allowed paths.static ContainerConfigvoidEnables localhost custom domain name for testing.Returns the list of custom domain names enabled for the applicationReturns the name of the default charset appended to theContent-Typeheader if no charset is specified by the request.intReturns the maximum amount of time (in milliseconds) set for the initialization time.Returns the base path configured in the container.Returns the list of file paths that the servlet accepts read/write requests tobooleanisBinaryContentType(String contentType) Determine if specified content type has been configured as binarybooleanbooleanWhether the framework will run exception thrown by the application through the implementation ofExceptionHandler.booleanWhether query string parameters in the request should be case sensitive or not.booleanbooleanTells whether the stage name passed in the request should be added to the context path:AwsProxyHttpServletRequest.getContextPath().voidsetConsolidateSetCookieHeaders(boolean consolidateSetCookieHeaders) Tells the library to consolidate multiple Set-Cookie headers into a single Set-Cookie header with multiple, comma-separated values.voidsetDefaultContentCharset(String defaultContentCharset) Sets the default charset value for theContent-Typeheader if no charset is specified with a request.voidsetDisableExceptionMapper(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.voidsetInitializationTimeout(int initializationTimeout) Sets the initialization timeout.voidsetQueryStringCaseSensitive(boolean queryStringCaseSensitive) Sets whether query string parameter names should be treated as case sensitive.voidsetServiceBasePath(String serviceBasePath) Configures a base path that can be stripped from the request path before passing it to the framework-specific implementation.voidsetStripBasePath(boolean stripBasePath) Whether this framework should strip the base path mapping specified with thesetServiceBasePath(String)method from a request before passing it to the framework-specific implementationsvoidsetUriEncoding(String uriEncoding) Sets the charset used to URLEncode and Decode request paths.voidsetUseStageAsServletContext(boolean useStageAsServletContext) Sets whether the API Gateway stage name should be included in the servlet context path.voidsetValidFilePaths(List<String> validFilePaths) Sets a list of valid file paths for the servlet to read/write from.
-
Field Details
-
DEFAULT_URI_ENCODING
- See Also:
-
DEFAULT_CONTENT_CHARSET
- See Also:
-
-
Constructor Details
-
ContainerConfig
public ContainerConfig()
-
-
Method Details
-
defaultConfig
-
getServiceBasePath
Returns the base path configured in the container. This configuration variable is used in conjuction withsetStripBasePath(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
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 thesetServiceBasePath(String)method from a request before passing it to the framework-specific implementations- Parameters:
stripBasePath-
-
getUriEncoding
-
setUriEncoding
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
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
Sets a list of valid file paths for the servlet to read/write from.- Parameters:
validFilePaths- A populated list of base paths
-
addValidFilePath
Adds a new base path to the list of allowed paths.- Parameters:
filePath- The base path
-
addCustomDomain
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
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 tofalsefor backward compatibility.- Returns:
trueif 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 isfalsefor backward compatibility.- Parameters:
queryStringCaseSensitive- Tells the framework to treat query string parameter names as case sensitive
-
addBinaryContentTypes
Configure specified content type(s) as binary- Parameters:
contentTypes- list of exact content types that will be considered as binary
-
isBinaryContentType
Determine if specified content type has been configured as binary- Parameters:
contentType- content type to query- Returns:
-
getDefaultContentCharset
Returns the name of the default charset appended to theContent-Typeheader if no charset is specified by the request. The default value of this isISO-8859-1.- Returns:
- The name of the default charset for the Content-Type header
-
setDefaultContentCharset
Sets the default charset value for theContent-Typeheader if no charset is specified with a request. The default value of this isISO-8859-1. If a request specifies aContent-Typeheader without acharsetproperty, 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 thesetInitializationTimeout(int)for additional details.- Returns:
- The max time allocated for initialization
-
setInitializationTimeout
public void setInitializationTimeout(int initializationTimeout) Sets the initialization timeout. When using an asyncInitializationWrapperthe 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 ofExceptionHandler. When this parameter is set to false the Lambda container handler object lets the Exception propagate upwards to the Lambda handler class.- Returns:
trueif exception mapping is disabled,falseotherwise.
-
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 totrueto disable exception mapping,falseotherwise.
-