Detailed Description
Storage of evidence on a flowData object.
- Examples
- usageSharing/usageSharing.js.
Public Member Functions | |
| constructor (flowData) | |
| Constructor for evidence. | |
| add (key, value) | |
| Add a piece of evidence to flowData. | |
| addObject (evidenceObject) | |
| Add a piece of evidence to flowData as an object. | |
| addFromRequest (request) | |
| Add evidence to flowData from an HTTP request This helper automatically adds evidence: headers, cookies, protocol, IP, query params and, for a POST with a form body, the form values. | |
| addFromRequestAsync (request, maxFormBytes=1024 *1024) | |
| Add evidence to flowData from an HTTP request, first reading a form body from the request when it is a POST with a form body and nothing has read the body already. | |
| get (key) | |
| Get a piece of evidence. | |
| getAll () | |
| Get all evidence. | |
Member Function Documentation
◆ add()
|
inline |
Add a piece of evidence to flowData.
- Parameters
-
{string} key evidence key to add {*} value value of evidence key
◆ addFromRequest()
|
inline |
Add evidence to flowData from an HTTP request This helper automatically adds evidence: headers, cookies, protocol, IP, query params and, for a POST with a form body, the form values.
Form values are added as query evidence after the query string, so a form value replaces a query string value of the same name. They are read from request.body, which a framework's form parser sets, either as an object or as the body text. A plain Node request has no request.body, so use addFromRequestAsync to read the body from the request instead. The 51Degrees client script sends its values in a form body, so without one or the other they never reach the pipeline.
- Parameters
-
{object} request an HTTP request object
- Returns
- {Evidence} return updated evidence
◆ addFromRequestAsync()
|
inline |
Add evidence to flowData from an HTTP request, first reading a form body from the request when it is a POST with a form body and nothing has read the body already.
The body text is kept in request.body, and then addFromRequest adds the evidence. A body larger than maxFormBytes is not read and no form values are added.
- Parameters
-
{object} request an HTTP request object {number} [maxFormBytes] the largest form body read, one mebibyte unless given
- Returns
- {Promise<Evidence>} the updated evidence
◆ addObject()
|
inline |
Add a piece of evidence to flowData as an object.
- Parameters
-
{object} evidenceObject key value map of evidence {string} evidenceObject.key evidencekey {*} evidenceObject.value evidence value
◆ constructor()
|
inline |
Constructor for evidence.
- Parameters
-
{FlowData} flowData FlowData to add the evidence to
◆ get()
|
inline |
Get a piece of evidence.
- Parameters
-
{string} key evidence key to retreive
- Returns
- {*} the evidence value
◆ getAll()
|
inline |
Get all evidence.
- Returns
- {object} all evidence
