From ded802b1b3a4f91fd550aae443961f181b3ca50e Mon Sep 17 00:00:00 2001 From: uwaa Date: Fri, 25 Oct 2024 06:56:00 +0100 Subject: [PATCH] cleanup --- Example/Program.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Example/Program.cs b/Example/Program.cs index ad12fc5..fa41e44 100644 --- a/Example/Program.cs +++ b/Example/Program.cs @@ -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 Websocket(HttpRequest client) + static async Task Websocket(HttpRequest client) { Websocket? ws = await client.UpgradeToWebsocket("test"); if (ws == null) - return null; + return new Empty(); DataFrame payload = await ws.Read();