Refactor Stumps to use a factory to generate an HTTP response for a stump rather than having a Stump directly tied to a static response. This allows Stumps to dynamically modify the response. Further, providing the originating HTTP request to the factory can allow the response to be modified based on the content of the incoming request.
Example Code
Before
class Stump {
// Other Code Here ...
public IStumpsHttpResponse Response
{
get => _response;
set => _response = value ?? throw new ArgumentNullException(nameof(value));
}
}
After
class Stump {
// Other Code Here ...
public IHttpResponseFactory ResponseFactory
{
get => _responseFactory;
set => _responseFactory = value ?? throw new ArgumentNullException(nameof(value));
}
}
Refactor Stumps to use a factory to generate an HTTP response for a stump rather than having a Stump directly tied to a static response. This allows Stumps to dynamically modify the response. Further, providing the originating HTTP request to the factory can allow the response to be modified based on the content of the incoming request.
Example Code
Before
After
interface IHttpResponseFactory { IStumpsHttpResponse CreateResponse(IStumpsHttpRequest request); }