This chapter covers
- Getting started with Actix
- Writing a RESTful web service
In this chapter, we will build our first real web service.
The web service will expose a set of APIs over HTTP, and will use the Representational State Transfer (REST) architectural style.
We’ll build the web service using Actix, a lightweight web framework written in Rust, which is also one of the most mature in terms of code activity, adoption and ecosystem. We will warm-up by writing introductory code in Actix to understand its foundational concepts and structure. Later, we will design and build a set of REST APIs using an in-memory data store that is thread-safe.
The complete code for this chapter can be found at https://github.com/peshwar9/rust-servers-services-apps.
Let’s get started.
Why Actix?
This book is about developing high performance web services and applications in Rust. The web frameworks considered while writing this book were Actix, Rocket, Warp and Tide. While Warp and Tide are relatively newer, Actix and Rocket lead the pack in terms of adoption and level of activity. Actix was chosen over Rocket as Rocket does not yet have native async support, and async support is a key factor to improve performance in I/O-heavy workloads (such as web service apis) at scale.
In this book, you are going to build a digital storefront aimed at tutors.