An open API service indexing awesome lists of open source software.

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

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/).