cleanup
This commit is contained in:
parent
900736ca78
commit
ded802b1b3
1 changed files with 8 additions and 11 deletions
|
@ -8,7 +8,7 @@ using MiniHTTP.Routing;
|
|||
|
||||
namespace MiniHTTP.Example;
|
||||
|
||||
internal partial class Program
|
||||
static class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
@ -25,9 +25,11 @@ internal partial class Program
|
|||
Router router = CreateRouter();
|
||||
HttpServer httpServer = new HttpServer(80, null, router);
|
||||
HttpServer httpsServer = new HttpServer(443, cert, router);
|
||||
_ = httpServer.Start();
|
||||
_ = httpsServer.Start();
|
||||
|
||||
Console.WriteLine("Ready on ports " + httpServer.Port + " and " +httpsServer.Port);
|
||||
Task.WaitAll(httpServer.Start(), httpsServer.Start());
|
||||
Console.WriteLine($"Ready on ports {httpServer.Port} and {httpsServer.Port}");
|
||||
Task.Delay(-1).Wait();
|
||||
}
|
||||
|
||||
static Router CreateRouter()
|
||||
|
@ -50,26 +52,21 @@ internal partial class Program
|
|||
return new HttpContent("text/html", await File.ReadAllBytesAsync("www-static/index.htm"));
|
||||
}
|
||||
|
||||
static HttpResponse? Test(HttpRequest client, ParameterCollection parameters)
|
||||
static HttpResponse Test(HttpRequest client, ParameterCollection parameters)
|
||||
{
|
||||
return new Redirect("/");
|
||||
}
|
||||
|
||||
static HttpResponse? Test2(HttpRequest client, ParameterCollection parameters)
|
||||
{
|
||||
return new OK("Hello");
|
||||
}
|
||||
|
||||
static HttpResponse NotFound(HttpRequest client, ParameterCollection parameters)
|
||||
{
|
||||
return new NotFound("File not found");
|
||||
}
|
||||
|
||||
static async Task<HttpResponse?> Websocket(HttpRequest client)
|
||||
static async Task<HttpResponse> Websocket(HttpRequest client)
|
||||
{
|
||||
Websocket? ws = await client.UpgradeToWebsocket("test");
|
||||
if (ws == null)
|
||||
return null;
|
||||
return new Empty();
|
||||
|
||||
DataFrame payload = await ws.Read();
|
||||
|
||||
|
|
Loading…
Reference in a new issue