-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can't borrow from the request in handlers with the current trait, and axum intentionally doesn't use lifetime generics in there, partly because that would just make the trait harder to grasp for users. But also, the current design has the The only thing you can do to avoid cloning is to take ownership of the header by removing it from the headers (which means it won't be available for subsequent extractors). |
Beta Was this translation helpful? Give feedback.
You can't borrow from the request in handlers with the current trait, and axum intentionally doesn't use lifetime generics in there, partly because that would just make the trait harder to grasp for users. But also, the current design has the
FromRequest
trait consume the request, which is incompatible with keeping borrows to the request around for the handler function.The only thing you can do to avoid cloning is to take ownership of the header by removing it from the headers (which means it won't be available for subsequent extractors).