Class RequestHandler
java.lang.Object
com.pixelservices.flash.components.http.RequestHandler
- Direct Known Subclasses:
BaseHandler
,SimpleHandlerWrapper
Base class for all request handlers
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map
<String, ExpectedBodyField> protected Map
<String, ExpectedBodyFile> protected Map
<String, ExpectedRequestParameter> protected Request
protected Response
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionexpectedBodyField
(String fieldName) Specify an expected body fieldexpectedBodyField
(String fieldName, String description) Specify an expected body field with descriptionexpectedBodyFile
(String fieldName) Specify an expected body fileexpectedBodyFile
(String fieldName, String description) Specify an expected body file with descriptionexpectedRequestParameter
(String parameterName) Specify an expected request parameterexpectedRequestParameter
(String parameterName, String description) Specify an expected request parameter with descriptionGet the handler typeGet the request objectorg.json.JSONObject
Get the request body as a JSONObjectstatic org.json.JSONObject
getRequestBody
(Request req) Get the request objectGet the response objectGet the handler specificationabstract Object
handle()
Handle the requestboolean
Check if the enforceNonNullBody flag is set in the RouteInfo annotationvoid
setHandlerType
(HandlerType handlerType) Sets the handler type (package-private)void
setRequestResponse
(Request req, Response res) Set the request and response objectsvoid
setSpecification
(HandlerSpecification specification) Sets the handler specification
-
Field Details
-
req
-
res
-
expectedRequestParameters
-
expectedBodyFields
-
expectedBodyFiles
-
-
Constructor Details
-
RequestHandler
Constructor for RequestHandler- Parameters:
req
- The Request objectres
- The Response object
-
-
Method Details
-
getHandlerName
-
isEnforcedNonNullBody
public boolean isEnforcedNonNullBody()Check if the enforceNonNullBody flag is set in the RouteInfo annotation- Returns:
- True if the enforceNonNullBody flag is set, false otherwise
-
getRequestBody
public org.json.JSONObject getRequestBody()Get the request body as a JSONObject- Returns:
- The request body as a JSONObject
-
getRouteParameters
-
getRequestBody
Get the request object- Returns:
- The request object
-
expectedRequestParameter
Specify an expected request parameter with description- Parameters:
parameterName
- The name of the parameterdescription
- The description of the parameter- Returns:
- The ExpectedRequestParameter object
-
expectedRequestParameter
Specify an expected request parameter- Parameters:
parameterName
- The name of the parameter- Returns:
- The ExpectedRequestParameter object
-
expectedBodyField
Specify an expected body field with description- Parameters:
fieldName
- The name of the fielddescription
- The description of the field- Returns:
- The ExpectedBodyField object
-
expectedBodyField
Specify an expected body field- Parameters:
fieldName
- The name of the field- Returns:
- The ExpectedBodyField object
-
expectedBodyFile
Specify an expected body file with description- Parameters:
fieldName
- The name of the filedescription
- The description of the file- Returns:
- The ExpectedBodyFile object
-
expectedBodyFile
Specify an expected body file- Parameters:
fieldName
- The name of the file- Returns:
- The ExpectedBodyFile object
-
getRequest
Get the request object- Returns:
- The request object
-
getResponse
Get the response object- Returns:
- The response object
-
getExpectedRequestParameters
- Returns:
- The expected request parameters
-
getExpectedBodyFields
- Returns:
- The expected body fields
-
getExpectedBodyFiles
- Returns:
- The expected body files
-
setRequestResponse
Set the request and response objects- Parameters:
req
- The request objectres
- The response object
-
getSpecification
Get the handler specification- Returns:
- The handler specification
-
setSpecification
Sets the handler specification- Parameters:
specification
- The handler specification
-
getHandlerType
Get the handler type- Returns:
- The handler type
-
setHandlerType
Sets the handler type (package-private)- Parameters:
handlerType
- The handler type
-
handle
Handle the request- Returns:
- The response object
-