Created
May 7, 2020 13:14
-
-
Save davidrosenstark/df95ed4ccf0bcf70b2efac7f8883c956 to your computer and use it in GitHub Desktop.
flask_injector_setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from injector import inject | |
from flask import request, g | |
@inject | |
def api_before_request(db_connection: MyDbConnectionClass): | |
if not request.path.startswith("/health_check"): | |
logger.info(f"Request received to: {request.url}, headers: {request.headers}, body: {request.json}”) | |
g.user_info = db_connection.query_user_info(request.headers.get('Username’)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment