Context
Descriptive full API of a Context.
A part of the context method is linked to the default ResponseHandler provided by Idylle. Specific method are design to adapt HTTP code when responding to an HTTP Request. For a better understanding feel free to check the HTTP Code Meaning.
Properties
data : Object { String: Any }
params : Object { String: String }
token: String
user: Object { String: Any }
session: Object { String: Any }
files: Array<File>
args: Object { String : Any }
criteria: Criteria
Note the properties will depends on the CriteriaBuilder
used by the Action. It can be overridden globally during the initialization phase or for a specific action by overriding the criteriaBuilder property.
Methods
.error(code, message, ...args) -> Promise (rejected)
.error(code, message, ...args) -> Promise (rejected)
create a rejection with a ContextError.
.ok(resource) -> resource
context.ok(resource) -> resource
changes the state of the context to tell the default ResponseHandler
that the response should be a 200 OK.
.created(resource) -> resource
context.created(resource) -> resource
changes the state of the context to tell the default ResponseHandler
that the response should be a 201 Created and let the response body empty.
Note that if the provided resource has a property uri
it will be written in the location
response header.
.partial(resource) -> resource
context.partial(resource) -> resource
changes the state of the context to tell the default ResponseHandler
that the response should be a 206 Partial.
.redirect(code=302, url) -> void
context.redirect(code, url) -> void
changes the state of the context to tell the default ResponseHandler
that the response should be a 301 Moved Permanently. Generally used when a deprecated method is still called from an old client.
.stream(path | buffer) -> resource
context.stream(path | buffer) -> void
changes the state of the context to tell the default ResponseHandler
that a File
or Buffer
has to be downloaded from the given path.
.noContent(resource) -> resource
context.noContent(resource) -> resource
changes the state of the context to tell the default ResponseHandler
that the response should be a 204 No Content and let the response body empty.
Last updated