I'm working in a .netstandard library, because it should work both in .NetFramework 4.7 and .NetCore. In that library, I have a method that receives a HttpRequest object, process the request using querystring, content, contenttype etc and returns a HttpResponse.
I've tried to use HttpRequestMessage and HttpResponseMessage, but in .NetCore API, we do not have those classes. Which is the best class to use in this situation for HttpRequest and HttpResponse?
Example:
public interface IOcspResponder
{
Task<HttpResponseMessage> Respond(HttpRequestMessage httpRequest);
}
The client will implement a controller and use the library the following way:
[RoutePrefix("api/ocsp")]
public class OcspController : Controller
{
[Route("{encoded}"]
public Task<HttpResponseMessage> Get(string encoded)
{
return await OcspResponder.Respond(Request);
}
[Route("")]
public Task<HttpResponseMessage> Post()
{
return await OcspResponder.Respond(Request);
}
private IOcspResponder OcspResponder { get; }
public OcspController(IOcspResponder ocspResponder)
{
OcspResponder = ocspResponder;
}
}