An HTTP request message is the unit a server routes and handles. The server receives a TCP byte stream, converts it into a request, selects a handler, and sends the handler’s response back as bytes. POST is the method used here when a client submits data for processing, such as form fields or a new course. section 2.3 section 8.4 section 9.5
A request has parts the handler can use:
- A request line supplies the method, resource path, and HTTP version. The Rust parser recognizes GET and POST as method variants. section 2.3.1
- Headers hold named values; a message body holds submitted content. The Rust HttpRequest struct stores headers in a HashMap and the body as a String. section 2.3.1
- A route connects the request path and method to a handler. The handler can extract a path value and deserialize a JSON body before doing its work. section 3.1.1 section 9.5
Listing 2.6 Data structures for the HTTP request
use std::collections::HashMap;
#[derive(Debug, PartialEq)]
pub enum Resource {
Path(String),
}
#[derive(Debug)]
pub struct HttpRequest {
pub method: Method,
pub version: Version,
pub resource: Resource,
pub headers: HashMap<String, String>,
pub msg_body: String,
}
The HttpRequest listing shows the typed representation produced from an incoming request: method, version, resource, headers, and message body. section 2.3.1
Submit a course with POST
Send `curl -X POST localhost:8080/courses/new/1` with a JSON body containing course details and the header `Content-Type: application/json`. The course handler reads tutor ID `1` from the path and accepts the body as `web::Json<NewCourse>`, then calls the backend service to create the course. A GET request to `localhost:3000/courses/1` checks that it was added. section 9.5
An HTML form uses the same method differently: submitting registration data sends a POST request to an Actix route. The handler can validate the input, re-render the form with an error, or continue processing. For sign-in, it checks submitted credentials against a local database and either redisplays the form or directs the user to the home page. section 8.4 section 9.1
At the low level, parsing turns request text into Rust structs and enums; in an Actix application, routes and typed handler parameters let application code work with extracted data. These examples cover GET and POST in the hand-built parser and practical POST handling, not a complete HTTP parser. section 2.3.1 section 9.5













