The Call Context is an object containing contextual information relating
to the current request or process. It is global to all scripts under the name
context.
app
The application object for the currently running application.
env
A map containing the list of properties and their values associated with the current environment. This may include passwords, keys and certificates, environment specific host or property names and more.
request
An object representing the inbound HTTP request if the context was created through an HTTP request. This object contains the following properties:
params (object) - a map of the combined request query string and POSTed
parameter names and values if any.headers (object) - a map of the header names and values in the HTTP request.cookies (object) - a map of the cookie names and values in the HTTP request
if any.stream (object) - an input stream object that can be used to stream the payload
to a consumer that is not the default payload processing consumer. Note that
this becomes unavailable once the payload processing commences. If this
is used first, the processing of the payload will not occur. Closing this
input stream also prevents the default payload processing from occurring.
This object is useful if there is a binary or non-standard payload than needs
to be handled independently of the default payload processing or if it needs
to be streamed to an external location.response
An object representing the outbound HTTP response if the context was created through an HTTP request. This object contains the following properties:
headers (object) - a map of the header names and values in the HTTP response.
These can be set at any time prior to the completion of the request. Several
standard HTTP response headers are reserved and may result in an error if an attempt
is made to set them.cookies (object) - a map of the cookie names and values in the HTTP response
to be sent back to the caller. Again these can be set at any time prior to
the completion of the request.stream (object) - an output stream object that can be used to stream a customised
payload back to the caller. Closing this output stream also prevents all subsequent
processing from occurring. This object is useful if there is a binary or non-standard
payload than needs to be handled returned to the caller. context.request.stream and
context.response.stream can be used together to stream binary or custom content
in and out of the Appirator environment without undergoing internal process
with the exception of request authentication
which does not normally need access to the request body (although it does use request
headers and query string parameters).event
This is set within an event handler irrespective of whether it is asynchronous or not. This is an object containing the event attributes. Specifically:
name (string) - the name of the event. For events triggered through CRUDS
operations on a resource object, these take the format $class.<id-of-resource-class>.<operation>.operation (enum) - the operation that triggered the event if triggered
through a resource object operation.source (object) - the object on which the event was triggered if any.target (object) - the object on which the event is run if any.
This becomes the this pointer (or equivalent depending on language).params (object) - a map containing any custom parameters associated with
the event.operation
The operation that occurred that caused the context to be created when the cause is related to a resource object. This can be one of:
It is important to note that the operation value in a context can change even through a single process. For example, the context may have been created through a READ operation of a particular resource, but in running a script related to that READ operation, the script may update another resource. When the second resource is being updated, the context will momentarily be assigned the UPDATE operation. The reason for this is that access and other rules need to run with respect to the contextual information and the operation being performed. A user might be allowed to read a resource, but they may not be allowed to update it.
See Operations for more information.
subject
An object containing the properties of the subject, i.e. the human or thing that is making the request. The specific properties in this object depend on the type of subject. The only reserved property in the subject is a list of permissions associated with the request, which may be a lazy loaded or virtualised list.
See Authentication & Authorisation for more information.