3 Building a RESTful web service

 

This chapter covers

  • Getting started with Actix
  • Writing a RESTful web service

In this chapter, we will build our first real web service. It will expose a set of APIs over HTTP, and it will use the representational state transfer (REST) architectural style.

We’ll build the web service using Actix (https://actix.rs), 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 some introductory code in Actix so you can learn its foundational concepts and structure. Later in this chapter, we will design and build a set of REST APIs using a thread-safe in-memory data store.

The complete code for this chapter can be found at https://git.manning.com/agileauthor/eshwarla/-/tree/master/code.

3.1 Getting started with Actix

In this book, we are going to build a digital storefront aimed at tutors. We’ll call our digital platform EzyTutors because we want tutors to be able to easily publish their training catalogs online, which can in turn trigger the interest of learners and generate sales.

To kickstart this journey, we’ll build a set of simple APIs that allow tutors to create courses and learners to retrieve courses.

3.1.1 Writing the first REST API

3.1.2 Understanding Actix concepts

3.2 Building web APIs with REST

3.2.1 Defining the project scope and structure

3.2.2 Defining and managing application state

3.2.3 Defining the data model

3.2.4 Posting a course

3.2.5 Getting all the courses for a tutor

3.2.6 Getting the details of a single course

Summary

sitemap