Reviewing the API Controllers
In this lesson, we'll go through and review the API Controllers
Reviewing our controllers#
Now, as you can see here, we have some data as a part of the response. If you're following along, you'll see the same data here. We can see this response because we hit the
You can see this beautifully managed because Swagger is taking care of this. As we discussed in the last lesson, Swagger is a documentation tool for our API. So all the endpoints we make in our project will be displayed on this page. You can run it or troubleshoot it. Currently, we only have one endpoint,
weatherForecast which comes bootstrapped with our Web API project. This was just a little overview of Swagger, but as mentioned, we will be using
Postman to test our endpoints.
Now let's go back to our code. You saw the response; now let's see why we saw what we saw. Inside the API project, we have a
controllers folder, and our controller folder has a
WeatherForecastController. Now you can guess where the weatherForecast endpoint came from. As we saw in the last lesson, we have Configure method which has a middleware called
app.UseRouting(). This middleware looks at the enpoint of the http request and sends it to the appropriate controller.