Exemple #1
0
def get_application(db):
    app = falcon.API()

    for exception_class in freezer_api_exc.exception_handlers_catalog:
        app.add_error_handler(exception_class, exception_class.handle)

    endpoint_catalog = [
        ('/v1', v1.public_endpoints(db)),
        ('/', [('', versions.Resource())])
    ]
    for version_path, endpoints in endpoint_catalog:
        for route, resource in endpoints:
            app.add_route(version_path + route, resource)

    # pylint: disable=no-value-for-parameter
    app = middleware.json_translator(app)

    if 'keystone_authtoken' in config.CONF:
        app = auth_token.AuthProtocol(app, {})
    else:
        logging.warning(_i18n._LW("keystone authentication disabled"))

    app = middleware.HealthApp(app=app, path='/v1/health')

    return app
Exemple #2
0
def build_app(db=None):
    """
    Building routes and forming the root freezer-api app
    :param db: instance of elastic search db class if not freezer will try to
    initialize this instance itself
    :return: wsgi app
    """
    if not db:
        db = driver.get_db()
    # injecting FreezerContext & hooks
    middleware_list = [utils.FuncMiddleware(hook) for hook in
                       utils.before_hooks()]
    middleware_list.append(middleware.JSONTranslator())
    middleware_list.append(middleware.RequireJSON())
    app = falcon.API(middleware=middleware_list)

    for exception_class in freezer_api_exc.exception_handlers_catalog:
        app.add_error_handler(exception_class, exception_class.handle)

    endpoint_catalog = [
        ('/v1', v1.public_endpoints(db)),
        ('/', [('', versions.Resource())])
    ]
    for version_path, endpoints in endpoint_catalog:
        for route, resource in endpoints:
            app.add_route(version_path + route, resource)

    return app
Exemple #3
0
def configure_app(app, db=None):
    """Build routes and exception handlers

    :param app: falcon WSGI app
    :param db: Database engine (ElasticSearch)
    :return:
    """
    if not db:
        db = driver.get_db()

    # setup freezer policy
    policy.setup_policy(CONF)

    for exception_class in freezer_api_exc.exception_handlers_catalog:
        app.add_error_handler(exception_class, exception_class.handle)

    endpoint_catalog = [
        ('/v1', v1.public_endpoints(db)),
        ('/', [('', versions.Resource())])
    ]
    for version_path, endpoints in endpoint_catalog:
        for route, resource in endpoints:
            app.add_route(version_path + route, resource)

    return app
Exemple #4
0
def get_application(db):
    app = falcon.API(middleware=[middleware.JSONTranslator()])

    for exception_class in exceptions.exception_handlers_catalog:
        app.add_error_handler(exception_class, exception_class.handle)

    endpoint_catalog = [('/v1', v1.public_endpoints(db)),
                        ('/', [('', versions.Resource())])]
    for version_path, endpoints in endpoint_catalog:
        for route, resource in endpoints:
            app.add_route(version_path + route, resource)

    if 'keystone_authtoken' in config.CONF:
        app = auth_token.AuthProtocol(app, {})
    else:
        logging.warning("keystone authentication disabled")
    return app
Exemple #5
0
def get_application(db):
    app = falcon.API(middleware=[middleware.JSONTranslator()])

    for exception_class in exceptions.exception_handlers_catalog:
        app.add_error_handler(exception_class, exception_class.handle)

    endpoint_catalog = [
        ('/v1', v1.public_endpoints(db)),
        ('/', [('', versions.Resource())])
    ]
    for version_path, endpoints in endpoint_catalog:
        for route, resource in endpoints:
            app.add_route(version_path + route, resource)

    if 'keystone_authtoken' in config.CONF:
        app = auth_token.AuthProtocol(app, {})
    else:
        logging.warning("keystone authentication disabled")
    return app
Exemple #6
0
def configure_app(app, db=None):
    """Build routes and exception handlers

    :param app: falcon WSGI app
    :param db: Database engine (ElasticSearch)
    :return:
    """
    if not db:
        db = driver.get_db()

    # setup freezer policy
    policy.setup_policy(CONF)

    for exception_class in freezer_api_exc.exception_handlers_catalog:
        app.add_error_handler(exception_class, exception_class.handle)

    endpoint_catalog = [('', v1.public_endpoints(db))]
    for version_path, endpoints in endpoint_catalog:
        for route, resource in endpoints:
            app.add_route(version_path + route, resource)

    return app