src.service_manager module¶
-
class
src.service_manager.
ServiceManager
(app)¶ The ServiceManager is a light wrapper around FlaskAPI that allows us to perform additional processing when routes are registered.
-
formatted_routes
(host_url)¶ Returns a dictionary of endpoints that have been registered with the api. This is useful for displaying a summary of available endpoints.
Parameters: host_url (basestring) – The host address e.g. https://example.com Returns: A dict mapping endpoints to their corresponding route and summary. For example: >>> { >>> 'my_service': { >>> 'route': 'https://example.com/myservice/<string:some_arg>', >>> 'doc': 'This is my function. It takes one argument.' >>> } >>> }
-
register_route
(func, rule, **options)¶ Like
Flask.route()
but with additional processing. The route is stored in a list so we can keep track of all the exposed API endpoints.Parameters: - func (callable) – The function that will be executed for the URL rule.
- rule (basestring) – The URL rule to match in order to execute the endpoint.
- endpoint (basestring) – The name of the exposed endpoint. Flask itself assumes the name of the view function as the endpoint.
Returns: The registered function.
-
route
(rule, **options)¶ A decorator version of
register_route()
. This allows you to use the decorator syntax like:>>> @api.route('/') >>> def index():
Parameters: - rule (basestring) – The URL rule to match in order to execute the endpoint.
- endpoint (basestring) – The name of the exposed endpoint. Flask itself assumes the name of the view function as the endpoint.
-