Package com.spec.web.expresso.message
Class HttpRequest
java.lang.Object
com.spec.web.expresso.message.HttpRequest
-
Constructor Summary
ConstructorsConstructorDescriptionHttpRequest(jakarta.servlet.http.HttpServletRequest req) Constructs an instance of HttpRequest wrapping an HttpServletRequest. -
Method Summary
Modifier and TypeMethodDescriptionbody()Returns the Http body of the HttpRequest as String.jakarta.servlet.http.Cookie[]Returns list of cookies sent by the clientReturns the value of header for the specified header name.jakarta.servlet.http.HttpServletRequestReturn http servlet request which is used internally by Expresso.getMimeType(String fileName) Returns the mime type of file name passed to it.Returns a reader object to read request body.Retrives the path of the current request url.getRouteParams(String name) Get the route parameter value against the given namegetUrlParams(String name) Return the query parameter value against the namevoidsetCurrentUrlPattern(String currentUrlPattern) Sets the current url pattern
-
Constructor Details
-
HttpRequest
public HttpRequest(jakarta.servlet.http.HttpServletRequest req) Constructs an instance of HttpRequest wrapping an HttpServletRequest.- Parameters:
req- HttpServlet to wrap
-
-
Method Details
-
body
Returns the Http body of the HttpRequest as String.- Specified by:
bodyin interfaceRequest- Returns:
- payload in string format
- Throws:
IOException- May throw and IOException if it cannot read the body of response.
-
getRouteParams
Get the route parameter value against the given name- Specified by:
getRouteParamsin interfaceRequest- Parameters:
name- name of the route parameter , this name should be same as the name of the parameter mentioned in the url pattern. Ex: /user/:id so parameter name will be 'id'.- Returns:
- value of the parameter
-
getUrlParams
Return the query parameter value against the name- Specified by:
getUrlParamsin interfaceRequest- Parameters:
name- name of the query parameter- Returns:
- value of the query parameter
-
setCurrentUrlPattern
Sets the current url pattern- Parameters:
currentUrlPattern- Url pattern on which the current middlware is executing on.
-
getHttpServletRequest
public jakarta.servlet.http.HttpServletRequest getHttpServletRequest()Return http servlet request which is used internally by Expresso.- Returns:
- HttpServletRequest
-
getRequestPath
Retrives the path of the current request url.- Specified by:
getRequestPathin interfaceRequest- Returns:
- the path of the current request
-
getMimeType
Returns the mime type of file name passed to it.- Specified by:
getMimeTypein interfaceRequest- Parameters:
fileName- The file for which the mime type should be found out.- Returns:
- MIME type of the file
-
getCookies
public jakarta.servlet.http.Cookie[] getCookies()Returns list of cookies sent by the client- Specified by:
getCookiesin interfaceRequest- Returns:
- List of cookies
-
getReader
Returns a reader object to read request body.- Specified by:
getReaderin interfaceRequest- Returns:
- Reader instance to read request body.
- Throws:
IOException- IOException
-
getHeader
-