Module moonwalk.api

Moonwalk core module.

This module should contain everything API authors will need.

API definition classes

class Instantiate an API class.
model Instantiate an API model.
operation Instantiate an API operation.

Configuration fields

connection_modules Connection modules.
swagger_version Swagger version.
version Your API's version number.

Request handling functions

create_connection () Create a connection base object suitable for the current host environment.
get_connection (hostdata) Instantiate a new connection object.
handle_request (hostdata) handle the request.
load_class (path) Load an API class.


API definition classes

Each of these class constructors have the following special behavior: If the constructor is called with less than the documented number of arguments, it will return a continuation object that can be called or concatenated with any remaining arguments. This enables docstrings to be appended to operation functions as described in DecoratorsAndDocstrings, and it allows calling functions with only string and table literal arguments without any parentheses.
class
Instantiate an API class. See api.class constructor.
model
Instantiate an API model. See api.model constructor.
operation
Instantiate an API operation. See api.operation constructor.

Configuration fields

connection_modules
Connection modules.

A numeric table containing paths to implementations of connection.abstract .

Fields:

  • moonwalk/connection/cgi CGI support.
  • moonwalk/connection/luanode Experimental LuaNode support.
  • moonwalk/connection/mongoose Mongoose and Civetweb support.
  • moonwalk/connection/socket Support for built-in testing server.
swagger_version
Swagger version.

The version of the Swagger protocol being used. You probably don't need to change it.

Defaults to '1.2'.

version
Your API's version number.

Defaults to '1.0'.

Request handling functions

Call these from your controller. Call api:load_class once for each api.class module, then call api:handle_request .
create_connection ()
Create a connection base object suitable for the current host environment. request.

Returns:

    A connection object that will be instantiated once per
get_connection (hostdata)
Instantiate a new connection object.

Creates an instance of the base object returned by api:create_connection .

Parameters:

  • hostdata

Returns:

    The newly instantiated connection object.
handle_request (hostdata)
handle the request.

Parameters:

  • hostdata
load_class (path)
Load an API class.

Loads a module containing an api.class instance, and registers the class with the API.

Parameters:

  • path The module path to the API class.

Usage:

     local api = require "moonwalk"
     api.load "transaction"
     api.handle_request(...)
generated by LDoc 1.4.0