TextExtension

TextExtension

Extension for parsing text data from text/ media type responses. The text of the response will be available as the property text on the Resource. By default, only text/plain content type is handled, but other types can be included, or the extension can be used in 'wildcard' mode and accept text/*.

Constructor

new TextExtension()

Create a new text extension.

Parameters:
Name Type Attributes Description
options.wildcard Boolean <optional>

Whether the extension should operate in wildcard mode.

options.subTypes Array.<String> <optional>

The additional text subtypes that should be handled by the extension

Implements:
Source:

Methods

applies(data, headers, context) → {Boolean}

Determine whether this extension should be used to process a particular response

Parameters:
Name Type Description
data Object

The body of the response, pre-parsed if some form of JSON.

headers Object.<string, string>

The HTTP headers of the response

context Context

The context of the current resource/operation.

Implements:
Source:
Returns:

True if the extension should be used to process the response.

Type
Boolean

dataParser(data, headers, context) → {Array.<{name: String, value: Object}>}

Parse any field data that is part of the resource.

Parameters:
Name Type Description
data Object

The body of the response, pre-parsed if some form of JSON.

headers Object.<string, string>

The HTTP headers of the response

context Context

The context of the current resource/operation.

Implements:
Source:
Returns:

The fields, as an array of name/value pairs.

Type
Array.<{name: String, value: Object}>