How to create a RESTful web service in Rust
It has been almost three months since my last article, and I have missed writing about Rust!!
So here I am, and in this article, we will explore how we can quickly and easily create a RESTful web service in Rust leveraging the crate Rocket.
But first, what does RESTful even means?
REST principles
A web service can be qualified as Restful when it follows a set of architectural principles named Representation State Transfer aka REST :).
The REST paradigm embraces a stateless, cacheable, layer system with a client-server architecture, which provides a uniform interface between components while optionally providing code on demand.
They are the purest extension of the ideas behind the World Wide Web (WWW) project and, more often than not, confound with the HTTP protocol(more on HHTP here).
So let’s be creative and build a simple RESTful web service that will help us convert dogs’ years to human years!! (Simply put, one dog year equals seven human years).
Building a web service with Rocket
Like many different programming languages, Rust has multiple crates that help bootstrap a web service creation.