featurist / Selfishhttp
Licence: bsd-2-clause
self hosting HTTP server for testing in .net
Stars: ✭ 18
Selfish HTTP
Because at some point, you'll want your own HTTP server.
Installation
PM> Install-Package SelfishHttp
Lets See
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.
GET
using SelfishHttp;
...
var server = new Server(4567);
server.OnGet("/").RespondWith("hi, this is selfish HTTP!");
POST
var server = new Server(4567);
server.OnPost("/").Respond((req, res) => {
var requestBody = req.BodyAs<string>();
...
res.Headers["Location"] = "/newthingo";
res.Body = "all done";
});
Loads of other stuff
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.
License
BSD
We're Hiring!
Featurist provides full stack, feature driven development teams. Want to join us? Check out our career opportunities.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].