Exposing Web API

Our system needs to have some visibility to users, and therefore, at some point, we will need to build a user interface. This topic is covered in later chapters, but right now we need to be able to expose our application in a way that the future UI can be built on top of it. We expect our system to have more than one UI potentially. Think about a single-page web application (SPA) and a mobile app. As a backend for both types of front-ends, we need to build a web API. I would avoid the term REST API since it is much more than a simple web API and we aren't going to explore this topic in depth. Instead, we will concentrate on making some calls to our domain model via HTTP, to do something useful.

Let's start by creating an ASP.NET WebAPI controller, where we put handlers for some of the HTTP endpoints. To do this, we need to add a class to our Marketplace project, because right now we will not be working inside the domain model, but outside of it.

Before we add a controller, let's create a project folder called Api, to put all controllers and related services in one place. We will add different types of components to the application project later on, so it is better to keep things tidy from the beginning. 

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.234.24