Package com.xebialabs.restito.semantics
Class Action
java.lang.Object
com.xebialabs.restito.semantics.Action
- All Implemented Interfaces:
Applicable
Action is a modifier for Response
- See Also:
-
Response
-
Method Summary
Modifier and TypeMethodDescriptionorg.glassfish.grizzly.http.server.Responseapply(org.glassfish.grizzly.http.server.Response r) Perform the action with responsestatic ActionbytesContent(byte[] content) Writes bytes content to responsestatic ActionSets charset of the response (must come before stringContent/resourceContent Action)static ActionSets charset of the response (must come before stringContent/resourceContent Action)static ActionCreates a composite action which contains all passed actions and executes them in the same order.static Actioncomposite(Applicable... actions) Creates a composite action which contains all passed actions and executes them in the same order.static Actioncomposite(Collection<Applicable> applicables) Creates a composite action which contains all passed actions and executes them in the same order.static ActioncontentType(String contentType) Sets content type to the responsestatic Actioncustom(Function<org.glassfish.grizzly.http.server.Response, org.glassfish.grizzly.http.server.Response> f) Perform set of custom actions on responsestatic ActionSleeps so many milliseconds, emulating slow requests.static ActionSets key-value header on responsestatic ActionSets HTTP status 204 to responsestatic Actionnoop()Doing nothing.static Actionok()Sets HTTP status 200 to responsestatic ActionresourceContent(String resourcePath) Writes content and content-type of resource file to response.static ActionresourceContent(String resourcePath, String charset) CombinesresourceContent(String)andcharset(String)static ActionresourceContent(URL resourceUrl) Writes content using the specified encoding and content-type of resource file to response.static ActionresourceContent(URL resourceUrl, Charset charset) CombinesresourceContent(java.net.URL)andcharset(Charset)static Actionstatus(org.glassfish.grizzly.http.util.HttpStatus status) Sets HTTP status to responsestatic ActionstringContent(String content) Writes string content into response.static ActionstringContent(String content, Charset charset) Writes string content into response.static Actionsuccess()Sets HTTP status 200 to response.static ActionReturns unauthorized response with default realm namestatic Actionunauthorized(String realm) Returns unauthorized response
-
Method Details
-
apply
public org.glassfish.grizzly.http.server.Response apply(org.glassfish.grizzly.http.server.Response r) Perform the action with response- Specified by:
applyin interfaceApplicable
-
success
Sets HTTP status 200 to response. Consider usingok()as more concise and less ambiguous option.- See Also:
-
ok
Sets HTTP status 200 to response -
noContent
Sets HTTP status 204 to response -
status
Sets HTTP status to response -
resourceContent
Writes content and content-type of resource file to response. Tries to detect content type based on file extension. If can not detect - content-type is not set. For now there are following bindings:- .xml - `application/xml`
- .json - `application/xml`
-
resourceContent
CombinesresourceContent(String)andcharset(String) -
resourceContent
Writes content using the specified encoding and content-type of resource file to response. Tries to detect content type based on file extension. If can not detect, content-type is not set. For now there are following bindings:- .xml - `application/xml`
- .json - `application/xml`
-
resourceContent
CombinesresourceContent(java.net.URL)andcharset(Charset) -
bytesContent
Writes bytes content to response -
stringContent
Writes string content into response. Important: when using this method, the string gets encoded into a sequence of bytes using the platform's default charset. Please usestringContent(String, Charset)if you need to be specific about the encoding. -
stringContent
Writes string content into response. The passed charset is used: - To encoded the string into bytes; - As character set of the response. The latter will result in acharset=XXX
part ofContent-Type
header if and only if the header has been set in some way (e.g. by usingcontentType(String)action. See `integration.CharsetAndEncodingTest` for more details. -
header
Sets key-value header on response -
contentType
Sets content type to the response -
charset
Sets charset of the response (must come before stringContent/resourceContent Action) -
charset
Sets charset of the response (must come before stringContent/resourceContent Action) -
unauthorized
Returns unauthorized response with default realm name -
unauthorized
Returns unauthorized response -
custom
public static Action custom(Function<org.glassfish.grizzly.http.server.Response, org.glassfish.grizzly.http.server.Response> f) Perform set of custom actions on response -
composite
Creates a composite action which contains all passed actions and executes them in the same order. -
composite
Creates a composite action which contains all passed actions and executes them in the same order. -
composite
Creates a composite action which contains all passed actions and executes them in the same order. -
noop
Doing nothing. To be used in DSLs for nicer syntax. -
delay
Sleeps so many milliseconds, emulating slow requests.
-