DELETE – Deleting data

When we don't need data anymore, we can delete it. This is the purpose of the DELETE method. Use it in the branch as follows:

(&Method::DELETE, Some(id)) => {
if users.contains(id) {
users.remove(id);
response_with_code(StatusCode::OK)
} else {
response_with_code(StatusCode::NOT_FOUND)
}
},

This code checks whether the Slab contains the data and removes it with the remove method. We don't use the remove method right away because this expects the data to exist in the storage beforehand, and therefore panics if the data is absent.

Often, web services don't actually remove data and instead just mark it as deleted. This is a reasonable thing to do because it allows you to explore the data later and improve the efficiency of the service or the company. However, this is a risky practice. Users should be able to remove their data completely, because sensitive data can represent a threat. New laws, such as the GDPR law (https://en.wikipedia.org/wiki/General_Data_Protection_Regulation), protect the user's right to own their data and stipulate certain requirements for data protection. Violation of such laws may result in a fine. It's important to remember this when you work with sensitive data.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.224.30.19