Add a default handler
In some scenarios we want to use to built-in handlers without needing to specify any custom handlers. Unfortunately, this kind of usage will throw a NullReferenceException.
using (var httpServer = new HttpServer(new HttpRequestProvider()))
{
httpServer.Use(new TcpListenerAdapter(new TcpListener(IPAddress.Any, 80)));
httpServer.Use(new FileHandler());
// I don't want to write this line.
httpServer.Use((context, next) => Task.Factory.GetCompleted());
httpServer.Start();
}
I suggest adding a default handler that returns Task.Factory.GetCompleted(), or at least throws a more indicative exception.
Elad
Will be fixed until the weekend 👍
—
שני.
On Mon, Jul 13, 2015 at 12:20 AM, Elad Zelingher [email protected] wrote:
In some scenarios we want to use to built-in handlers without needing to specify any custom handlers. Unfortunately, this kind of usage will throw a NullReferenceException.
using (var httpServer = new HttpServer(new HttpRequestProvider())) { httpServer.Use(new TcpListenerAdapter(new TcpListener(IPAddress.Any, 80))); httpServer.Use(new FileHandler()); // I don't want to write this line. httpServer.Use((context, next) => Task.Factory.GetCompleted()); httpServer.Start(); }I suggest adding a default handler that returns Task.Factory.GetCompleted(), or at least throws a more indicative exception.
Elad
Reply to this email directly or view it on GitHub: https://github.com/Code-Sharp/uHttpSharp/issues/16