This can be done using the url_value_processor decorator:
@app.url_value_preprocessor def get_project_object(endpoint, values): api_key = values.get('api_key') if api_key is None: api_key = request.cookies.get('api_key', None) if api_key is None: raise Exception('api_key is required') values['api_key'] = api_key
It can also be done at the core of Blueprint, so it only applies to views in the specified Blueprint.
source share