I need deep help to understanding about Rocket.rs

Now I just started learning Roket.rs in Rust.
But I couldn't understand about Request Guard.
Please help me.

A request guard is basically a type that implements FromRequest. It can be passed as an argument to a request handler. Rocket under the hood retrieves a value for the request guard's type from the request (e.g. the request's body or its headers) or some application state that Rocket keeps track of, and passes that value to the request handler as an argument. The (approximate—implementation details differ) axum equivalent would be (the more appropriately named IMHO) extractor.

1 Like

For a practical example you may want to check...

  1. a User that submits a request –where it's defined,
  2. a request handler, w/ a User guard to check who is submitting the request and what premissions they're allowed –where it's used.
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.