-
Notifications
You must be signed in to change notification settings - Fork 8
Add clientToolName middleware #6
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
| class ClientToolNameMiddleware(BaseMiddleware): | ||
| def __init__(self, name="pythx"): | ||
| LOGGER.debug("Initializing") | ||
| self.name = name |
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.
Are we planning to add additional middleware or allow devs to build custom ones off of PythX?
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.
Developers can add their own middlewares, simply by adding them to the APIHandler, like
from foo import MyMiddleware
from pythx.api.handler import APIHandler
mw = MyMiddleware()
handler = APIHandler(middlewares=[mw])and then passing that to the Client class. I'm also hacking up a passthrough so you can do something like
c = Client(middlewares=[mw])to completely abstract from the API handler class.
| (CUSTOM_CTN_MIDDLEWARE, generate_request_dict(testdata.LOGOUT_REQUEST_OBJECT), False), | ||
| (CUSTOM_CTN_MIDDLEWARE, generate_request_dict(testdata.REFRESH_REQUEST_OBJECT), False), | ||
| ], | ||
| ) |
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.
Tests passed for me!
cache-monet
left a comment
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.
Really good stuff, I'm learning a lot just by reviewing the code 👍
Add a middleware that automatically fills in the
clientToolNamefield of analysis submission requests so people on the API side know PythX was used.