Home Identifier Source Repository
import Client from 'super-siren/lib/Client.js'
public class | source

Client

You can directly use instance of this class. client

HTTP client used by the Super-Siren library. Library utilized superaget for all requests.

Static Member Summary

Static Public Members
public static get

globalHeaders: Immutable.Map: *

Returns a Map of current global headers that are added

Static Method Summary

Static Public Methods
public static

action(method: *, href: *): *

public static

addHeader(header: String, value: String): undefined

Registers a global header to be used by all client instances.

public static

addParser(contentType: String, parseFunction: Function): undefined

Registers a content type parser with all client instances.

public static

del(href: *): *

public static

get(href: String): superagent-promise

Creates a superagent HTTP get operation

public static

post(href: *): *

public static

put(href: *): *

public static

Remves a previously registered global header.

Static Public Members

public static get globalHeaders: Immutable.Map: * source

Returns a Map of current global headers that are added for all clients.

Return:

Immutable.Map

Immutable map of all currently registered headers

Static Public Methods

public static action(method: *, href: *): * source

Params:

NameTypeAttributeDescription
method *
href *

Return:

*

public static addHeader(header: String, value: String): undefined source

Registers a global header to be used by all client instances.

Params:

NameTypeAttributeDescription
header String

The header attribute to set

value String

The header value to set

Return:

undefined

public static addParser(contentType: String, parseFunction: Function): undefined source

Registers a content type parser with all client instances.

Params:

NameTypeAttributeDescription
contentType String

content-type which should be parsed with the provided function whenever a response is received with this content type.

parseFunction Function

Function to call in order to return response body when response is encoded with the provided contentType.

Return:

undefined

public static del(href: *): * source

Params:

NameTypeAttributeDescription
href *

Return:

*

public static get(href: String): superagent-promise source

Creates a superagent HTTP get operation

Params:

NameTypeAttributeDescription
href String

The URL to perform an HTTP get against.

Return:

superagent-promise

superagent get request

public static post(href: *): * source

Params:

NameTypeAttributeDescription
href *

Return:

*

public static put(href: *): * source

Params:

NameTypeAttributeDescription
href *

Return:

*

public static removeHeader(header: String): undefined source

Remves a previously registered global header.

Params:

NameTypeAttributeDescription
header String

The header attribute to remove

Return:

undefined