Module ngx-oauth.nginx

Utilities for nginx.

Functions

add_response_cookies (cookies) Adds table of cookies to the response's Set-Cookie header.
fail (status, message, ...) Interrupts execution of the current request for a failure.
format_cookie (name, value, attrs) Formats HTTP cookie from the given arguments.
get_cookie (name) Returns URI-decoded value of the specified request's cookie.
get_uri_arg (name) Returns URI-decoded value of the specified request's URI argument (query parameter).
log (level, message, ...) Logs the given (formatted) message on the specified logging level.


Functions

add_response_cookies (cookies)
Adds table of cookies to the response's Set-Cookie header. If the header is already set, then the new cookies are appended to the existing ones.

Parameters:

See also:

fail (status, message, ...)

Interrupts execution of the current request for a failure.

  1. Logs the given error message with level ngx.WARN, if the status is less than 500, or ngx.ERR otherwise.

  2. Sends response with the specified HTTP status and JSON body:

    { "message": "The error message" }
    

Parameters:

  • status int The HTTP status code to send.
  • message string The error message to log and send.
  • ... Arguments for string.format being applied to message. Nil values are replaced with #nil.
format_cookie (name, value, attrs)
Formats HTTP cookie from the given arguments.

Parameters:

Returns:

    string A cookie string.
get_cookie (name)
Returns URI-decoded value of the specified request's cookie.

Parameters:

  • name string The name of the cookie to get.

Returns:

    string or nil The cookie's value, or nil if doesn't exist.
get_uri_arg (name)
Returns URI-decoded value of the specified request's URI argument (query parameter).

Parameters:

  • name string The name of the argument to get.

Returns:

    string or nil The argument's value, or nil if doesn't exist.
log (level, message, ...)
Logs the given (formatted) message on the specified logging level. There are 8 levels defined by ngx's constants (you can find list of them here).

This module also defines convenient functions for most common levels: log.err(), log.warn(), log.info(), and log.debug().

Parameters:

  • level int The logging level (0-8).
  • message string
  • ... Arguments for string.format being applied to message. Nil values are replaced with #nil.
generated by LDoc 1.4.3