A request extractor is an Actix Web component that supplies typed request or application data to a handler as an argument. It connects incoming HTTP data and shared application state to request-processing code. section 4.4.2 section 3.2.1
Common Actix Web extractors include:
- `web::Data<AppState>` provides shared application state, such as a database connection pool, to handlers. section 3.2.1 section 4.4.2
- `web::Path<(i32, i32)>` extracts numeric path parameters such as `tutor-id` and `course-id` as a tuple. section 4.4.2 section 9.4
- `web::Form<Tutor>` extracts submitted form data into a typed structure, making the submitted `name` available to the handler. section 7.4
Extracting route parameters
A course-details handler can accept `app_state: web::Data<AppState>` and `params: web::Path<(i32, i32)>`. Read `params.0`, convert the tuple values to the required integer type, pass them with `&app_state.db` to the database function, and serialize the returned course with `HttpResponse::Ok().json(course)`.
Processing submitted form data
A POST handler can accept `params: web::Form<Tutor>`, insert `params.name` into a Tera context, and render `user.html`. A browser form posts the `name` field to `/tutors`.
