Package io.nitric.faas.http
Class HttpContext.Request
- java.lang.Object
-
- io.nitric.faas.http.HttpContext.Request
-
- Enclosing class:
- HttpContext
public static class HttpContext.Request extends Object
Provides a HTTP request object.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getData()
Return the HTTP request body data.String
getDataAsText()
Return the HTTP request body data (UTF-8 encoded) as text, or an empty string if not defined.Map<String,Object>
getExtras()
Return the request extras map.String
getHeader(String name)
Return the first HTTP header value for the given name, or null not found.Map<String,List<String>>
getHeaders()
Return an immutable map of HTTP request header values.String
getMethod()
Return the HTTP request method [ GET | POST | PUT | DELETE ].String
getMimeType()
Return the HTTP request MIME Type or "Content-Type" header value, or an empty string if not defined.String
getPath()
Return HTTP request path, or an empty string if not defined.Map<String,String>
getPathParams()
Return the request URL path params map.String
getQueryParam(String name)
Return the first HTTP query parameter value for the given name, or null not found.Map<String,List<String>>
getQueryParams()
Return an immutable map of HTTP request query parameters.String
toString()
Return the string representation of this object.
-
-
-
Constructor Detail
-
Request
public Request(String method, String path, Map<String,List<String>> headers, Map<String,List<String>> queryParams, String mimeType, byte[] data, Map<String,String> pathParams, Map<String,Object> extras)
Create a new Request object.- Parameters:
method
- the method of the HTTP requestpath
- the path of the HTTP requestheaders
- the headers of the HTTP requestqueryParams
- the query parameters of the HTTP requestmimeType
- the request mime-typedata
- the HTTP body datapathParams
- the request URL path parametersextras
- the request extra attributes
-
-
Method Detail
-
getMethod
public String getMethod()
Return the HTTP request method [ GET | POST | PUT | DELETE ].- Returns:
- the HTTP request method
-
getPath
public String getPath()
Return HTTP request path, or an empty string if not defined.- Returns:
- HTTP request path, or an empty string if not defined
-
getHeader
public String getHeader(String name)
Return the first HTTP header value for the given name, or null not found.- Parameters:
name
- the HTTP header name (required)- Returns:
- the first HTTP header value for the given name, or null not found.
-
getHeaders
public Map<String,List<String>> getHeaders()
Return an immutable map of HTTP request header values. If no headers are present an empty map will be returned.- Returns:
- map of HTTP request header values
-
getQueryParam
public String getQueryParam(String name)
Return the first HTTP query parameter value for the given name, or null not found.- Parameters:
name
- the HTTP query parameter name (required)- Returns:
- the first HTTP query parameter value for the given name, or null not found.
-
getQueryParams
public Map<String,List<String>> getQueryParams()
Return an immutable map of HTTP request query parameters. If no parameters are present then an empty map will be returned.- Returns:
- an immutable map of HTTP request query parameter values
-
getMimeType
public String getMimeType()
Return the HTTP request MIME Type or "Content-Type" header value, or an empty string if not defined.- Returns:
- the HTTP request MIME Type or "Content-Type" header value
-
getData
public byte[] getData()
Return the HTTP request body data. If no data is present a zero length array will be returned.- Returns:
- the HTTP request body data
-
getDataAsText
public String getDataAsText()
Return the HTTP request body data (UTF-8 encoded) as text, or an empty string if not defined.- Returns:
- the HTTP request body data (UTF-8 encoded) as text, or an empty string if not defined.
-
getPathParams
public Map<String,String> getPathParams()
Return the request URL path params map. The request pathParams map provides support for custom middleware enhancements to the context request.- Returns:
- the request URL path parameters, or an empty map if not defined
-
getExtras
public Map<String,Object> getExtras()
Return the request extras map. The request extras map provides support for custom middleware enhancement to the context request.- Returns:
- the request extras attributes, or an empty map if not defined
-
-