-
Book Overview & Buying
-
Table Of Contents
Rust Web Programming - Third Edition
By :
PATCH methods are essentially the same as a POST method. We want to put the data in the JSON body. However, the PATCH method is typically used for updating parts of a resource that have already been created. If we were to update the entire resource, then we would use the PUT method.
This is the last endpoint that we create in this chapter. Here, we want to accept a to-do item in the JSON body, get the item, and update it. This is a good point to try and build the API endpoint yourself. As a hint, it is advisable to start with the core, calling the data access layer. Here, you can load the items, check that the item is there, and update the item, inserting the updated item back into the state and writing the state. Once this is done, you then move on to the networking layer, which calls the core update function.
To build our API endpoint, we begin by importing the following:
//! File: nanoservices/to_do/core/src/api/basic_actions...