refactor: Decouple extractors from AppContext using FromRef#1735
refactor: Decouple extractors from AppContext using FromRef#1735mccormickt wants to merge 1 commit intoloco-rs:masterfrom
AppContext using FromRef#1735Conversation
374204b to
fb40396
Compare
FromRef on AppContextAppContext using FromRef
|
Thanks for the clean work here! A few questions before we move forward:
|
|
Thanks for
There are a few nice properties of this change that I believe still uphold this motivation: By deriving By modifying our extractors, we allow external crates to utilize helpful middleware we may implement, by not explicitly relying on AppContext. I don't believe we should be restrictive where we don't need to be.
I agree this is not a technically necessary change, but seemed more "correct" in that the JWT methods there don't require anything but data in Those are my strong opinions, loosely held! The main gains are in the |
|
I agree on the core value here, deriving However, I'd like to propose we split this into two steps: Step 1 (this PR): Just derive Step 2 (follow-up PR): Loosen our built-in extractor bounds + the
Could you restructure this PR to just the Thoughts? |
e1f5555 to
0b2793b
Compare
This allows extractors to pull out fields of `AppContext` as [substates](https://docs.rs/axum/0.8.8/axum/extract/struct.State.html\#substates) in handlers through [`FromRef::from_ref`](https://docs.rs/axum/latest/axum/extract/trait.FromRef.html)
0b2793b to
1587a48
Compare
|
Done - I've pulled out the commit changing |
This PR derives
FromRef::from_refonAppContextto allow extractors to pull out fields ofAppContextas substates in handers. It also refactors our existing extractors to be able to work with any state that implementsFromRefto pull out the required substate (e.g.DatabaseConnection,Config,SharedStore,Cache, etc.).