A web service exposes application functionality to network clients through HTTP APIs. Serving JSON at an API path is a starting point: unlike serving a static HTML page, the server is returning data for a client to use. A useful first implementation handles GET requests and returns JSON, though a fuller service needs more than GET alone. section 2.0 section 2.3.5
Build the service in stages. First, a small Rust HTTP server makes TCP and HTTP request handling visible without a framework. Next, Actix Web supplies the structure for REST APIs backed by a thread-safe in-memory store. A database-backed iteration adds routes, a model, application state, an injected SQLx connection pool, and unit tests before completing the handlers. section 2.0 section 3.0 section 4.3
A course service and its client
A tutor-facing service exposes RESTful APIs for course data stored in Postgres; a separate server-rendered web app consumes the backend APIs. For a tutor list, the frontend makes a GET request, deserializes the JSON response into a typed Rust value, and renders it. Calling the service rather than querying Postgres again avoids duplicating database access logic and placing database credentials in both applications. section 1.3.1 section 7.7
#[derive(Serialize, Deserialize, Debug)]
pub struct Tutor {
pub tutor_id: i32,
pub tutor_name: String,
pub tutor_pic_url: String,
pub tutor_profile: String,
}
The Tutor struct shows the typed shape expected by the frontend when it deserializes a web-service JSON response. section 7.7





