https://github.com/featurist/selfishhttp
self hosting HTTP server for testing in .net
https://github.com/featurist/selfishhttp
Last synced: 5 months ago
JSON representation
self hosting HTTP server for testing in .net
- Host: GitHub
- URL: https://github.com/featurist/selfishhttp
- Owner: featurist
- License: bsd-2-clause
- Created: 2012-10-08T15:33:39.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2018-02-09T14:29:23.000Z (almost 8 years ago)
- Last Synced: 2025-04-18T14:06:56.349Z (9 months ago)
- Language: C#
- Homepage:
- Size: 57.6 KB
- Stars: 18
- Watchers: 7
- Forks: 14
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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();
...
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](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing).
* Stream bodies.
* An [connect](http://www.senchalabs.org/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](https://github.com/featurist/SelfishHttp/tree/master/SelfishHttp.Test) for examples.
### License
BSD
## We're Hiring!
Featurist provides full stack, feature driven development teams. Want to join us? Check out [our career opportunities](https://www.featurist.co.uk/careers/).