# Path: drift/core/extensions/jwt.py
# def query_current_user():
#     """
#     Return the current jwt payload if the user has been authenticated
#     """
#     return getattr(_request_ctx_stack.top, 'drift_jwt_payload', None)
# 
# def jwt_not_required(fn):
#     log.debug("Registering open endpoint in module : %s", fn.__module__)
#     _open_endpoints.add(fn)
#     return fn


import logging
import json
import uuid
import traceback
import sys
from six import StringIO
from flask import make_response, jsonify, request, current_app
from werkzeug.exceptions import HTTPException
from flask_smorest import abort
from drift.core.extensions.jwt import query_current_user, jwt_not_required
    Setup tracking metadata for the http requests and responses
"""
from __future__ import absolute_import




log = logging.getLogger(__name__)


def drift_init_extension(app, **kwargs):

    # app.handle_exception = partial(handle_all_exceptions, app.handle_exception)
    # app.handle_user_exception = partial(handle_all_exceptions, app.handle_user_exception)

    @app.errorhandler(500)
    @app.errorhandler(503)
    def deal_with_exceptions(e):
        return handle_all_exceptions(e)

    @app.errorhandler(400)
    @app.errorhandler(401)
    @app.errorhandler(403)
    @app.errorhandler(404)
    @app.errorhandler(405)
    @app.errorhandler(422)
    def deal_with_aborts(e):
        return handle_all_exceptions(e)

    # Health check endpoint. Always succeedes.

# Path: drift/core/extensions/jwt.py
# def query_current_user():
#     """
#     Return the current jwt payload if the user has been authenticated
#     """
#     return getattr(_request_ctx_stack.top, 'drift_jwt_payload', None)
# 
# def jwt_not_required(fn):
#     log.debug("Registering open endpoint in module : %s", fn.__module__)
#     _open_endpoints.add(fn)
#     return fn


# Path: drift/core/extensions/apierrors.py
import logging
import json
import uuid
import traceback
import sys
from six import StringIO
from flask import make_response, jsonify, request, current_app
from werkzeug.exceptions import HTTPException
from flask_smorest import abort
from drift.core.extensions.jwt import query_current_user, jwt_not_required

    Setup tracking metadata for the http requests and responses
"""
from __future__ import absolute_import




log = logging.getLogger(__name__)


def drift_init_extension(app, **kwargs):

    # app.handle_exception = partial(handle_all_exceptions, app.handle_exception)
    # app.handle_user_exception = partial(handle_all_exceptions, app.handle_user_exception)

    @app.errorhandler(500)
    @app.errorhandler(503)
    def deal_with_exceptions(e):
        return handle_all_exceptions(e)

    @app.errorhandler(400)
    @app.errorhandler(401)
    @app.errorhandler(403)
    @app.errorhandler(404)
    @app.errorhandler(405)
    @app.errorhandler(422)
    def deal_with_aborts(e):
        return handle_all_exceptions(e)

    # Health check endpoint. Always succeedes.

    @jwt_not_required