6 Evolving the APIs and fearless refactoring

 

This chapter covers

  • Revamping the project structure
  • Enhancing the data model for course creation and management
  • Enabling tutor registration and management

In the previous chapter, we covered the basics of error handling in Rust and how we can design custom error handling for our web service. After working through the last few chapters, you should now have a foundational understanding of how a web service is structured using the Actix Web framework, how you can talk to a relational database for CRUD activities, and how to handle any errors that occur while processing incoming data and requests. In this chapter, we will step up the pace and deal with something that we cannot avoid in the real world: changes.

Every actively used web service or application evolves significantly over its lifecycle, based on user feedback or business requirements. Many of these new requirements could mean breaking changes to the web service or application. In this chapter, you’ll learn how Rust helps you cope with situations involving drastic design changes and the rewriting of significant parts of your existing code. You’ll use the power of the Rust compiler and the features of the language to come out of this challenge with a smile on your face.

6.1 Revamping the project structure

6.2 Enhancing the data model for course creation and management

6.2.1 Making changes to the data model

6.2.2 Making changes to the course APIs

6.3 Enabling tutor registration and management

6.3.1 Data model and routes for tutors

6.3.2 Handler functions for tutor routes

6.3.3 Database access functions for tutor routes

6.3.4 Database scripts for tutors

6.3.5 Run and test the tutor APIs

Summary