Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion flask_log_request_id/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from . import parser


__version__ = '0.10.1'
__version__ = '0.10.2'


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion flask_log_request_id/request_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _persist_request_id():
setattr(g, g_object_attr, self._request_id_generator())

# Register after request
if self.app.config['LOG_REQUEST_ID_LOG_ALL_REQUESTS']:
if app.config['LOG_REQUEST_ID_LOG_ALL_REQUESTS']:
app.after_request(self._log_http_event)

@staticmethod
Expand Down
8 changes: 8 additions & 0 deletions tests/request_id_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ def setUp(self):
self.app.route('/')(lambda: 'hello world')
self.app.testing = True

def test_lazy_initialization(self):
# Bug #38: https://github.com/Workable/flask-log-request-id/issues/38
request_id = RequestID()
request_id.init_app(self.app)
with self.app.test_request_context(headers={'X-Amzn-Trace-Id': 'Self=1-67891234-def;Root=1-67891233-abc'}):
self.app.preprocess_request()
self.assertEqual('1-67891234-def', current_request_id())

def test_default_request_id_parser_with_amazon(self):
RequestID(self.app)
with self.app.test_request_context(headers={'X-Amzn-Trace-Id': 'Self=1-67891234-def;Root=1-67891233-abc'}):
Expand Down