Module restia.handler

Loads configurations from files on demand.

Info:

  • License: Unlicense
  • Author: DarkWiiPlayer

Functions

xpcall (action, handler) Similar to Luas xpcall, but exits the nginx request in case of error.
serve (handlermodule[, errormodule="error"][, action], ...) Serves a handler.

Local Functions

exit_on_failure (success, ...) Handles the result of xpcall.


Functions

xpcall (action, handler)
Similar to Luas xpcall, but exits the nginx request in case of error. A custom message handler takes care of logging and rendering an error message. This function is still very much work in progress and its behavior may change.

Parameters:

  • action function The code that should run in “protected” mode to handle the request (a module name).
  • handler function The error handler, which may return a HTTP error code.

Returns:

    The return value of the action function.
serve (handlermodule[, errormodule="error"][, action], ...)
Serves a handler. This is a higher-level wrapper to handler.xpcall that requires a module. If no action is given, the module is assumed to return a handler function directly. If the action is given, the module is treated as a table and deep-indexed with action to get the handler function.

Parameters:

  • handlermodule string The module name to require to get the handler.
  • errormodule string The module name of the error handler. (default "error")
  • action string The table path to the event handler. (optional)
  • ... Additional arguments to be passed to the handler.

Local Functions

exit_on_failure (success, ...)
Handles the result of xpcall. Exits on error.

Parameters:

  • success Whether the function ran successfully.
  • ... A list of return values to be passed through.
generated by LDoc 1.4.6 Last updated 2021-01-03 16:45:09