You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a9e3a33 refactor(http): extract Axum extractor for the URL path param key (Jose Celano)
Pull request description:
Axum extractor to extract the `key` path param from the URLs:
```rust
Router::new()
// Announce request
.route("/announce", get(announce::handle_without_key).with_state(tracker.clone()))
.route("/announce/:key", get(announce::handle_with_key).with_state(tracker.clone()))
// Scrape request
.route("/scrape", get(scrape::handle_without_key).with_state(tracker.clone()))
.route("/scrape/:key", get(scrape::handle_with_key).with_state(tracker.clone()))
// Add extension to get the client IP from the connection info
.layer(SecureClientIpSource::ConnectInfo.into_extension())
```
It extracts the `:key` param. I'm using an extractor because we have a custom error response, and the handlers are much cleaner this way and we remove the duplicate code.
Top commit has no ACKs.
Tree-SHA512: a414de88ecda5ddba589d7716821238dcfd8fd179ec96fca195578cf0f7c3558949cb403da7845ee36fa52f338c3187ad4b9744e7dc05d92d4e404cc7a8f02c0
0 commit comments