unrest.framework

Framework

Framework(self, app, url)

UnRest Framework abstract class.

Framework are instanciated with an app object which should be your framework instance and the url of this UnRest instance.

You must implement the register_route method if you want to implement you own framework.

Arguments

  • app: Your framework instance used in register_route to register route.
  • url: The current UnRest url ('/api' by default)

external_url

A property returning the external api url root. (Used in OPTIONS and openapi genration)

register_route

Framework.register_route(path, method, parameters, function)

This method is called by your rest endpoints for each path and each method that should respond with the function. The route should allow optionally the parameters within the url. These parameters represent the primary keys.

Arguments

  • path: The url of the endoint without arguments. ('/api/person')
  • method: The HTTP method to register the route on.
  • parameters: The primary keys of the model that can be given after the path. PrimaryKey('id'), PrimaryKey('type')) -> '/api/person/<id>/<type>'
  • function: The route function

unrest.framework.http_server

HTTPServerFramework

HTTPServerFramework(self, app, url)

Unrest Framework implementation for http.server.HTTPServer compatible app.

This exemple implementation requires no external library.

unrest.framework.flask

FlaskFramework

FlaskFramework(self, app, url)

Unrest Framework implementation for Flask.

Requires flask to be installed.

unrest.framework.tornado

TornadoFramework

TornadoFramework(self, app, url)

Unrest Framework implementation for Tornado.

Requires tornado to be installed.