January 2019
Intermediate to advanced
520 pages
14h 32m
English
When the server has just started, it doesn't contain any data. To support data creation, we use the POST method without the user's ID. Add the following branch to the match (method, user_id) expression:
(&Method::POST, None) => { let id = users.insert(UserData); Response::new(id.to_string().into())}
This code adds a UserData instance to the user database and sends the associated ID of the user in a response with the OK status (an HTTP status code of 200). This code was set by the Response::new function by default.
Read now
Unlock full access