Skip to content

featurist/SelfishHttp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.