-
Notifications
You must be signed in to change notification settings - Fork 252
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
Feat: Enable passing in Extras using Custom Annotations #706
Conversation
… into feat/typed-extras
Hi @farmery , thanks for the great work. Lets bump the lib versions and update the change logs before we merge that changes. |
… into feat/typed-extras
Hi @trevorwang I just updated the change logs and versions |
New version has been deployed @farmery |
@farmery What a timing! @trevorwang Could you copy-paste the example provided here to the docs? |
@farmery |
Would you like to submit a PR for this? @moshe5745 |
Sure |
Summary
This PR adds functionality that allows developers to pass extras with requests using custom classes.
Problem
Imagine you want every request in your app to include some additional metadata, such as an id and a region. Without this feature, you would have to annotate each request manually with something like Extra({'id': '1234', 'region': 'ng'}). While this approach works, it requires passing the key-value pairs each time, which introduces several risks:
Developers may inadvertently misspell a key (e.g., regoin instead of region).
A required key might be forgotten or omitted.
The repeated manual input increases the chance of inconsistency,
Solution
Introduce
TypedExtras
, which developers can extend to provide extras in a structured and type-safe manner. By defining fields within the custom class, developers can avoid manual key-value entry, ensuring consistency and reducing the risk of errors.Example: