API Docs for: 0.7.5
Show:

Http.server Class

Access point: ac.http.* This is a server-only utility plugin that makes many server side resources available for mojit code that will never run on the client.

Methods

addHeader

(
  • key
  • val
)

Adds a header to the response without overriding previous values

Parameters:

  • key String

    header name.

  • val String

    header value.

addHeaders

(
  • hdrs
)

Adds a object of headers all at once, adding to previous values

Parameters:

  • hdrs Object

    header values to add.

getHeader

(
  • name
)
Object

Returns one request header value

Parameters:

  • name String

    header name.

Returns:

Object: header value.

getHeaders

() Object

Returns all request headers

Returns:

Object: all headers.

getRequest

() ServerRequest

Returns the HTTP request.

Returns:

ServerRequest: The node.js http.ServerRequest instance.

getResponse

() ServerResponse

Returns the HTTP response object from the request.

Returns:

ServerResponse: The node.js http.ServerResponse instance.

isXhr

() Boolean

Helper to tell you if this is an XHR request. Checks specifically for the 'x-requested-with' header.

Returns:

Boolean: True if the receiver is associated with an XHR request.

redirect

(
  • uri
  • code
)

This redirect is an external redirect. It causes an HTTP status code 301 by default.

Parameters:

  • uri String

    the URI to redirect to.

  • code Number

    [optional] if not specifed, 301.

setHeader

(
  • key
  • val
)

Sets a header by key, overriding previous values

Parameters:

  • key String

    header name.

  • val String

    header value.

setHeaders

(
  • hdrs
)

Sets a object full of headers all at once, overriding previous values

Parameters:

  • hdrs Object

    header values to set.