Responsibilities of a web adapter
What does a web adapter actually do? Let’s say we want to provide a REST API for our BuckPal application. Where do the responsibilities of the web adapter start and where do they end?
A web adapter usually does these things:
- Maps the incoming HTTP request to objects.
- Performs authorization checks.
- Validates the input.
- Maps the request objects to the input model of the use case.
- Calls the use case.
- Maps the output of the use case back to HTTP.
- Returns the HTTP response.
First of all, a web adapter must listen to HTTP requests that match certain criteria such as a URL path, HTTP method, and content type. The parameters and the content of a matching HTTP request must then be deserialized into objects we can work with.
Commonly, a web adapter then does an authentication and authorization check and returns an error if it fails.
The state of the incoming objects can then be validated. But haven’...