uHttpSharp icon indicating copy to clipboard operation
uHttpSharp copied to clipboard

Add a default handler

Open darkl opened this issue 10 years ago • 1 comments

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

darkl avatar Jul 12 '15 21:07 darkl

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

shanielh avatar Jul 13 '15 08:07 shanielh