new ApiRequest()
Represents a context of the running code
Do not call constructor directly
Bluenimble container creates it internally and makes it available for your services to use
Do not call constructor directly
Bluenimble container creates it internally and makes it available for your services to use
- Source:
Members
(readonly) api :string
The api namespace resolved to run this request
Type:
- string
- Source:
(readonly) channel :string
The channel from where this request is coming from http, coap, mqtt or container
Type:
- string
- Source:
(readonly) device :JsonObject
The device making this request
Type:
- JsonObject
Properties:
Name | Type | Description |
---|---|---|
origin |
string | the ip or hostname of the application or device |
lang |
string | the language of the application or user |
agent |
string | the software used to make the request |
os |
string | the operating system of the calling application or device |
- Source:
(readonly) endpoint :string
The server endpoint of this request
Type:
- string
- Source:
(readonly) headers :Array
Request headers http headers, coap options or mqtt attributes
Type:
- Array
- Source:
(readonly) id :string
The id of this request
Type:
- string
- Source:
(readonly) lang :string
The language of the the calling device of application
Type:
- string
- Source:
(readonly) params :Array
Request parameters
Type:
- Array
- Source:
(readonly) parent :Array
The path of this request
Type:
- Array
- Source:
(readonly) path :Array
The path of this request
Type:
- Array
- Source:
(readonly) resource :Array
The array of resources resolved from the path
Type:
- Array
- Source:
(readonly) service :ApiService
The service resolved by the container to execute this request
Type:
- Source:
(readonly) space :string
The space resolved for this request
Type:
- string
- Source:
(readonly) streams :Array
Request streams such as file uploads
Type:
- Array
- Source:
(readonly) timestamp :Date
The time when this request was created/received by the container
Type:
- Date
- Source:
(readonly) track :ApiRequestTrack
The request track.
Type:
- Source:
(readonly) verb :string
The verb of this request GET, POST, PUT, DELETE
Type:
- string
- Source:
Methods
get(key, scopeopt) → {Object}
Get a value from a specific scope
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string | the name of the parameter, header or stream | ||
scope |
ApiRequest.Scope |
<optional> |
ApiRequest.Scope.Parameter | the scope of the key ApiRequest.Scope.Parameter, ApiRequest.Scope.Header or ApiRequest.Scope.Stream |
- Source:
Returns:
the value of the parameter, header or stream
- Type
- Object
set(key, value, scopeopt)
Set a parameter, header
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string | the name of the parameter or header | ||
value |
Object | the value of the parameter or header | ||
scope |
ApiRequest.Scope |
<optional> |
ApiRequest.Parameter | the scope of the key ApiRequest.Parameter or ApiRequest.Header |
- Source:
toJson() → {JsonObject}
Get a json representation of this request
- Source:
Returns:
request as a json object
- Type
- JsonObject
withPrefix(prefix, scopeopt) → {JsonObject}
Get parameters starting with a specific prefix
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
prefix |
string | prefix | ||
scope |
ApiRequest.Scope |
<optional> |
ApiRequest.Parameter | the scope. ApiRequest.Parameter, ApiRequest.Header or ApiRequest.Stream |
- Source:
Returns:
an object with all parameters and corresponding values
- Type
- JsonObject