HttpContext

HttpContext

HttpContext

Constructor

new HttpContext(request, response) → {HttpContext}

Creates an instance of HttpContext class.
Parameters:
Name Type Description
request ClientRequest
response ServerResponse
Properties:
Name Type Description
mime Object Gets an object which represents the mime type associated with this context.
format string Gets a string which represents the response format of this context (e.g html, json, js etc).
Implements:
  • DataContext
Source:
Returns:
Type
HttpContext

Extends

  • DataContext
  • EventEmitter2

Members

application :HttpApplication

Type:
Source:

data :*

Gets an object that represents route data variables
Type:
  • *
Source:

params :*

Gets an object that represents HTTP context parameters
Type:
  • *
Source:

querystring :*

Gets an object that represents HTTP query string variables.
Type:
  • *
Source:

request :ClientRequest

Type:
  • ClientRequest
Source:

response :ServerResponse

Type:
  • ServerResponse
Source:

t

Translates the given string to the language specified in this context
Source:

user :*

Gets or sets the current user identity
Type:
  • *
Source:

Methods

Parameters:
Name Type Attributes Description
name string
value * <optional>
expires Date <optional>
domain string <optional>
cookiePath string <optional>
Source:
Returns:
Type
string | undefined

culture(valueopt)

Gets or sets the current culture
Parameters:
Name Type Attributes Description
value String <optional>
Source:

currentHandler(valueopt) → {function|Object}

Gets or sets the current HTTP handler
Parameters:
Name Type Attributes Description
value Object <optional>
Source:
Returns:
Type
function | Object

engine(extension) → {*}

Creates an instance of a view engine based on the given extension (e.g. ejs, md etc)
Parameters:
Name Type Description
extension string
Source:
Returns:
Type
*

handle(method, fn) → {HttpContext}

Parameters:
Name Type Description
method String | Array
fn function
Source:
Returns:
Type
HttpContext

handleDelete(fn)

Invokes the given function if the current HTTP method is equal to PUT
Parameters:
Name Type Description
fn function
Source:

handleGet(fn) → {HttpContext}

Invokes the given function if the current HTTP method is equal to GET
Parameters:
Name Type Description
fn function
Source:
Returns:
Type
HttpContext

handlePost(fn) → {HttpContext}

Invokes the given function if the current HTTP method is equal to POST
Parameters:
Name Type Description
fn function
Source:
Returns:
Type
HttpContext

handlePut(fn) → {HttpContext}

Invokes the given function if the current HTTP method is equal to PUT
Parameters:
Name Type Description
fn function
Source:
Returns:
Type
HttpContext

is(method)

Checks whether the HTTP method of the current request is equal or not to the given parameter.
Parameters:
Name Type Description
method String | Array The HTTP method (GET, POST, PUT, DELETE)
Source:

removeCookie(name, domainopt, cpathopt) → {string|undefined}

Parameters:
Name Type Attributes Description
name string The name of the cookie to be deleted
domain string <optional>
An optional parameter which indicates cookie's domain.
cpath string <optional>
An optional parameter which indicates cookie's path. The default value is the root path.
Source:
Returns:
Type
string | undefined

setCookie(name, value, expiresopt, domainopt, cpathopt) → {string|undefined}

Parameters:
Name Type Attributes Description
name string The name of the cookie to be added
value string | * The value of the cookie
expires Date <optional>
An optional parameter which sets cookie's expiration date. If this parameters is missing or is null a session cookie will be set.
domain string <optional>
An optional parameter which sets the cookie's domain.
cpath string <optional>
An optional parameter which sets the cookie's path. The default value is the root path.
Source:
Returns:
Type
string | undefined

translate(text, libopt) → {*}

Translates the given string to the language specified in this context
Parameters:
Name Type Attributes Description
text string The string to translate
lib string <optional>
A string that represents the library which contains the source string. This arguments is optional. If this argument is missing, then the operation will use the default (global) library.
Source:
Returns:
Type
*

unattended(fn, callback)

Executes the specified code in unattended mode.
Parameters:
Name Type Description
fn function
callback function
Source:

validateAntiForgeryToken(csrfTokenopt)

Performs cross-site request forgery validation against the specified token
Parameters:
Name Type Attributes Description
csrfToken string <optional>
Source:

HttpContext

new HttpContext()

Source:

Members

application :HttpApplication

Type:
Source:

data :*

Gets an object that represents route data variables
Type:
  • *
Source:

params :*

Gets an object that represents HTTP context parameters
Type:
  • *
Source:

querystring :*

Gets an object that represents HTTP query string variables.
Type:
  • *
Source:

request :ClientRequest

Type:
  • ClientRequest
Source:

response :ServerResponse

Type:
  • ServerResponse
Source:

t

Translates the given string to the language specified in this context
Source:

user :*

Gets or sets the current user identity
Type:
  • *
Source:

Methods

Parameters:
Name Type Attributes Description
name string
value * <optional>
expires Date <optional>
domain string <optional>
cookiePath string <optional>
Source:
Returns:
Type
string | undefined

culture(valueopt)

Gets or sets the current culture
Parameters:
Name Type Attributes Description
value String <optional>
Source:

currentHandler(valueopt) → {function|Object}

Gets or sets the current HTTP handler
Parameters:
Name Type Attributes Description
value Object <optional>
Source:
Returns:
Type
function | Object

engine(extension) → {*}

Creates an instance of a view engine based on the given extension (e.g. ejs, md etc)
Parameters:
Name Type Description
extension string
Source:
Returns:
Type
*

handle(method, fn) → {HttpContext}

Parameters:
Name Type Description
method String | Array
fn function
Source:
Returns:
Type
HttpContext

handleDelete(fn)

Invokes the given function if the current HTTP method is equal to PUT
Parameters:
Name Type Description
fn function
Source:

handleGet(fn) → {HttpContext}

Invokes the given function if the current HTTP method is equal to GET
Parameters:
Name Type Description
fn function
Source:
Returns:
Type
HttpContext

handlePost(fn) → {HttpContext}

Invokes the given function if the current HTTP method is equal to POST
Parameters:
Name Type Description
fn function
Source:
Returns:
Type
HttpContext

handlePut(fn) → {HttpContext}

Invokes the given function if the current HTTP method is equal to PUT
Parameters:
Name Type Description
fn function
Source:
Returns:
Type
HttpContext

is(method)

Checks whether the HTTP method of the current request is equal or not to the given parameter.
Parameters:
Name Type Description
method String | Array The HTTP method (GET, POST, PUT, DELETE)
Source:

removeCookie(name, domainopt, cpathopt) → {string|undefined}

Parameters:
Name Type Attributes Description
name string The name of the cookie to be deleted
domain string <optional>
An optional parameter which indicates cookie's domain.
cpath string <optional>
An optional parameter which indicates cookie's path. The default value is the root path.
Source:
Returns:
Type
string | undefined

setCookie(name, value, expiresopt, domainopt, cpathopt) → {string|undefined}

Parameters:
Name Type Attributes Description
name string The name of the cookie to be added
value string | * The value of the cookie
expires Date <optional>
An optional parameter which sets cookie's expiration date. If this parameters is missing or is null a session cookie will be set.
domain string <optional>
An optional parameter which sets the cookie's domain.
cpath string <optional>
An optional parameter which sets the cookie's path. The default value is the root path.
Source:
Returns:
Type
string | undefined

translate(text, libopt) → {*}

Translates the given string to the language specified in this context
Parameters:
Name Type Attributes Description
text string The string to translate
lib string <optional>
A string that represents the library which contains the source string. This arguments is optional. If this argument is missing, then the operation will use the default (global) library.
Source:
Returns:
Type
*

unattended(fn, callback)

Executes the specified code in unattended mode.
Parameters:
Name Type Description
fn function
callback function
Source:

validateAntiForgeryToken(csrfTokenopt)

Performs cross-site request forgery validation against the specified token
Parameters:
Name Type Attributes Description
csrfToken string <optional>
Source: