13 Middleware, HTTP routing, and HTTP responses

This chapter covers

  • Routing HTTP requests to controllers and endpoints
  • Declaring HTTP routes with HttpAttribute method attributes
  • Injecting dependencies with middleware
  • Using the IActionResult interface to return HTTP responses

We are almost at the end of our journey. In chapters gone by, we implemented the database access layer, the repository layer, and the service layer. Our service is almost implemented but not yet usable by FlyTomorrow (our client). To interact with our service, we need to provide controllers that accept HTTP requests and kick off the necessary processing.

In section 13.1, we’ll discuss the controller’s place within our repository/service architecture. Following that, in ...

Get Code like a Pro in C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.