Skip to content

Add a default handler #16

Open
Open
@darkl

Description

@darkl

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions