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.Response
apply
(org.glassfish.grizzly.http.server.Response r) Perform the action with responsestatic Action
bytesContent
(byte[] content) Writes bytes content to responsestatic Action
Sets charset of the response (must come before stringContent/resourceContent Action)static Action
Sets charset of the response (must come before stringContent/resourceContent Action)static Action
Creates a composite action which contains all passed actions and executes them in the same order.static Action
composite
(Applicable... actions) Creates a composite action which contains all passed actions and executes them in the same order.static Action
composite
(Collection<Applicable> applicables) Creates a composite action which contains all passed actions and executes them in the same order.static Action
contentType
(String contentType) Sets content type to the responsestatic Action
custom
(Function<org.glassfish.grizzly.http.server.Response, org.glassfish.grizzly.http.server.Response> f) Perform set of custom actions on responsestatic Action
Sleeps so many milliseconds, emulating slow requests.static Action
Sets key-value header on responsestatic Action
Sets HTTP status 204 to responsestatic Action
noop()
Doing nothing.static Action
ok()
Sets HTTP status 200 to responsestatic Action
resourceContent
(String resourcePath) Writes content and content-type of resource file to response.static Action
resourceContent
(String resourcePath, String charset) CombinesresourceContent(String)
andcharset(String)
static Action
resourceContent
(URL resourceUrl) Writes content using the specified encoding and content-type of resource file to response.static Action
resourceContent
(URL resourceUrl, Charset charset) CombinesresourceContent(java.net.URL)
andcharset(Charset)
static Action
status
(org.glassfish.grizzly.http.util.HttpStatus status) Sets HTTP status to responsestatic Action
stringContent
(String content) Writes string content into response.static Action
stringContent
(String content, Charset charset) Writes string content into response.static Action
success()
Sets HTTP status 200 to response.static Action
Returns unauthorized response with default realm namestatic Action
unauthorized
(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:
apply
in 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.
-