Skip to content

Commit

Permalink
Add support for Falcon framework requests
Browse files Browse the repository at this point in the history
  • Loading branch information
rhcarvalho committed Jun 8, 2018
1 parent d68e7d3 commit 2b58f41
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions rollbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ def log_handler(event):
except ImportError:
treq = None

try:
from falcon import Request as FalconRequest
except ImportError:
FalconRequest = None


def get_request():
"""
Expand Down Expand Up @@ -1054,6 +1059,10 @@ def _build_request_data(request):
if SanicRequest and isinstance(request, SanicRequest):
return _build_sanic_request_data(request)

# falcon
if FalconRequest and isinstance(request, FalconRequest):
return _build_falcon_request_data(request)

# Plain wsgi (should be last)
if isinstance(request, dict) and 'wsgi.version' in request:
return _build_wsgi_request_data(request)
Expand Down Expand Up @@ -1187,6 +1196,19 @@ def _build_sanic_request_data(request):
return request_data


def _build_falcon_request_data(request):
request_data = {
'url': request.url,
'user_ip': _wsgi_extract_user_ip(request.env),
'headers': dict(request.headers),
'method': request.method,
'GET': dict(request.params),
'context': dict(request.context),
}

return request_data


def _build_wsgi_request_data(request):
request_data = {
'url': wsgiref.util.request_uri(request),
Expand Down

0 comments on commit 2b58f41

Please sign in to comment.