The library to easy build rest-full web services based on asynchronous frameworks Module based ideology
import storm
REQUIRES = ("urlfetch",)
SETTINGS = [
{
"name": "opt1",
"help": "the option"
}
]
EXCEPTIONS = {ValueError: 400}
@storm.handler('get', 'test', wrap='json.output', secure=False)
def test(context, number: int, values: str, optional: bool=False):
return [number, values, optional]
- method The http method, see HTTP-Methods
- url The resource uri, can be relative or absolute
- secure If True, the method requires authentication, default: True.
- status Specify HTTP status for response, default: 200.
- wrap the comma separated list of wrappers, that can be applied for arguments and result, to more details see section Wrappers.
The function arguments are converted to input arguments by using standard python function argument annotation.
<name>:[<type>] [=default]
Each module can declare the following global variables:
The list of required modules, list of available modules: Modules
The optional settings, that should be provided by user
The exceptions class with associated http status, may be function f(e), where e is exception value.
- get "The HTTP GET method handler.
- put "The HTTP PUT method handler.
- post "The HTTP POST method handler.
- delete "The HTTP DELETE method handler.
- getx The method to get one instance, in case if argument "$key" is specified.
- query The method to get list of elements in case if argument "$key" is not specified.
- sql The sql database connector
- sql_master The comma separated list of master nodes
- sql_slave The coma separated list of slave nodes
- sql_user The username
- sql_password The username
- sql_timeout The connection timeout
- sql_retries The retries limit
- sql_delay The timeout between retries
- urlfetch The async http client
- urlfetch_root_ca The root CA
- urlfetch_validate_cert The certificate to validate server certificate
- urlfetch_client_cert The client certificate
- urlfetch_client_key The client key
- google The google API client * google_api_key The google application key * google_secret The google application secret
- json the json input and output formatting
- json.ouput transform only the function result