-
Notifications
You must be signed in to change notification settings - Fork 11
Add support for Falcon web framework #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Frank,
Thanks a lot for your contribution, the change looks nice! Please check my comments, there are few small things I would prefer to be changed.
best regards,
Georgi
This is needed in order to get the *correlation_id* generated at the beginning of the request or | ||
fetched from the HTTP headers. | ||
|
||
Falcon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add to the Features section the support for Falcon, I would suggest creating a bulleted list containing the supported frameworks.
class FalconRequestReader(RequestReader): | ||
def get_remote_user(self, request): | ||
remote_user = defaults.UNKNOWN | ||
http_auth = request.get_header('Authorization') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer not to parse auth headers into the logging lib, rather to support the most common authentication frameworks and the way they provide user info. I would suggest to read the user from the request context as expected to be set by falcon-auth authentication layer.
class LoggingMiddleware: | ||
|
||
def __init__(self, logger='cf.falcon.logger'): | ||
self.logger = logger |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name logger
suggest an object, but this is a name, can you name it like logger_name
for better readability?
The Falcon support has been added via: #15. |
This pull request adds support for Falcon by:
sap.cf_logging.falcon_logging.LoggingMiddleware
Context
,RequestReader
,ResponseReader
as adapter to Falconinit
to initialize CF Logging with Falcon connectionTests have been added and the Readme has been updated with an example.
Since Falcon does not provide a global context like Flask (with
flask.g
), it leverages thereq
object for context. Alog()
method gets attached to thereq
object in the middleware to avoid the necessity to provideextra
with the request object for logging (like in thesanic
implementation).