public interface RESTRequest
This interface encapsulates the artifacts pertaining to an HTTP request.
Implementations of this interface are not guaranteed to be thread safe, and live only until the corresponding
RESTHandler.handleRequest(RESTRequest, RESTResponse)
method returns.
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCompleteURL()
Returns the request URL, exactly as the request would have been made it.
|
java.lang.String |
getContentType()
Gets the content type of the request sent to the server.
|
java.lang.String |
getContextPath()
Returns the context path component of the request URL.
|
java.lang.String |
getHeader(java.lang.String key)
This method gives access to incoming REST headers.
|
java.io.Reader |
getInput()
This method gives access to the incoming REST body, if any.
|
java.io.InputStream |
getInputStream()
This method gives access to the InputStream.
|
java.util.Locale |
getLocale()
Returns the preferred Locale that the client will accept content in,
based on the Accept-Language header.
|
java.util.Enumeration<java.util.Locale> |
getLocales()
Returns an Enumeration of Locale objects indicating, in decreasing order
starting with the preferred locale, the locales that are acceptable to
the client based on the Accept-Language header.
|
java.lang.String |
getMethod()
Fetches the HTTP method (ie: GET, POST,DELETE, OPTIONS, PUT) corresponding to this REST request.
|
java.lang.String |
getParameter(java.lang.String name)
Fetches the value of a parameter.
|
java.util.Map<java.lang.String,java.lang.String[]> |
getParameterMap()
Fetches a map that contains all the requested parameters.
|
java.lang.String[] |
getParameterValues(java.lang.String name)
Fetches the values of a parameter.
|
java.io.InputStream |
getPart(java.lang.String partName)
To be used in conjunction with isMultiPartRequest, which should always be called before this method.
|
java.lang.String |
getPath()
Returns the path component of the request URL relative to the IBM API context root.
|
java.lang.String |
getPathVariable(java.lang.String variable)
Returns the actual value of a path variable in the incoming request.
|
java.lang.String |
getQueryString()
Returns the query string of the request URL.
|
java.lang.String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.
|
java.lang.String |
getRemoteHost()
Returns the fully qualified name of the client or the last proxy that sent the request.
|
int |
getRemotePort()
Returns the Internet Protocol (IP) source port of the client or last proxy that sent the request.
|
java.lang.String |
getSessionId() |
java.lang.String |
getURI()
Returns the URI component of the request URL.
|
java.lang.String |
getURL()
Returns the URL component of the request URL.
|
java.security.Principal |
getUserPrincipal()
Returns a java.security.Principal object containing the name of the current authenticated user.
|
boolean |
isMultiPartRequest()
Returns true if this is a multipart form request.
|
boolean |
isUserInRole(java.lang.String role)
Returns a boolean indicating whether the authenticated user is included in the specified logical "role".
|
java.io.Reader getInput() throws java.io.IOException
java.io.IOException
- if an I/O exception occurred.java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
- if an I/O exception occurred.java.lang.String getHeader(java.lang.String key)
key
- representing the header.java.lang.String getMethod()
java.lang.String getCompleteURL()
Returns the request URL, exactly as the request would have been made it. This includes the protocol, host, port, path and query string (if specified).
For example:
if the requested URL is https://localhost:9443/ibm/api/myRoot/myPath?param1=value1,param2=value2
then this method returns
https://localhost:9443/ibm/api/myRoot/myPath?param1=value1,param2=value2
java.lang.String getURL()
Returns the URL component of the request URL. The query string is not included.
For example:
if the requested URL is https://localhost:9443/ibm/api/myRoot/myPath?param1=value1,param2=value2
then this method returns
https://localhost:9443/ibm/api/myRoot/myPath
java.lang.String getURI()
Returns the URI component of the request URL. The query string is not included.
For example:
if the requested URL is https://localhost:9443/ibm/api/myRoot/myPath?param1=value1,param2=value2
then this method returns /ibm/api/myRoot/myPath
.
java.lang.String getContextPath()
Returns the context path component of the request URL.
For example:
if the requested URL is https://localhost:9443/ibm/api/myRoot/myPath?param1=value1,param2=value2
then this method returns /ibm/api
.
java.lang.String getPath()
Returns the path component of the request URL relative to the IBM API context root. The query string is not included.
For example:
if the requested URL is https://localhost:9443/ibm/api/myRoot/myPath?param1=value1,param2=value2
then this method returns /myRoot/myPath
java.lang.String getQueryString()
Returns the query string of the request URL.
For example:
if the requested URL is https://localhost:9443/ibm/api/myRoot/myPath?param1=value1,param2=value2
then this method returns param1=value1,param2=value2
.
java.lang.String getParameter(java.lang.String name)
getParameterMap()
name
- a java.lang.String representing the key of the parameter to be fetched.java.lang.String[] getParameterValues(java.lang.String name)
name
- a java.lang.String representing the key of the parameter to be fetched.java.util.Map<java.lang.String,java.lang.String[]> getParameterMap()
java.security.Principal getUserPrincipal()
boolean isUserInRole(java.lang.String role)
role
- a String specifying the name of the rolejava.lang.String getPathVariable(java.lang.String variable)
Example: A RESTHandler could register a root "/myRoot/{city}/schools/{school}", which would match to an incoming request of "/myRoot/Burlington/schools/NotreDame", and thus getPathVariable("city") returns Burlington while getPathVariable("school") returns NotreDame.
variable
- represents the name of the variable to fetchjava.util.Locale getLocale()
java.util.Enumeration<java.util.Locale> getLocales()
java.lang.String getRemoteAddr()
java.lang.String getRemoteHost()
int getRemotePort()
java.io.InputStream getPart(java.lang.String partName) throws java.io.IOException
partName
- multipart form part namejava.io.IOException
boolean isMultiPartRequest()
java.lang.String getContentType()
java.lang.String getSessionId()