Because at some point, you'll want your own HTTP server.
PM> Install-Package SelfishHttp
SelfishHttp is an easy to use HTTP server that you can configure with regular C# code. Great for mocking out real HTTP servers in tests.
using SelfishHttp;
...
var server = new Server(4567);
server.OnGet("/").RespondWith("hi, this is selfish HTTP!");
var server = new Server(4567);
server.OnPost("/").Respond((req, res) => {
var requestBody = req.BodyAs<string>();
...
res.Headers["Location"] = "/newthingo";
res.Body = "all done";
});
It supports:
- All the verbs: GET, PUT, POST, DELETE, OPTIONS, HEAD, PATCH. Any others?
- Basic Authentication.
- CORS.
- Stream bodies.
- An connect-like handler interface, for injecting HTTP handlers into the request/response pipeline.
- An expressive builder interface for building up handlers.
- Extensible body parsers and writers for different content types.
- Able to proxy requests to other servers.
- Option to disable client caching in response headers
See the tests for examples.
BSD
Featurist provides full stack, feature driven development teams. Want to join us? Check out our career opportunities.