Skip to content

Commit

Permalink
refactor HttpServer
Browse files Browse the repository at this point in the history
  • Loading branch information
bezzad committed Nov 18, 2023
1 parent 6bb374d commit 554b5fe
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net6.0;</TargetFrameworks>
<LangVersion>latestMajor</LangVersion>
<ServerGarbageCollection>true</ServerGarbageCollection>
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
<StartupObject>Downloader.DummyHttpServer.HttpServer</StartupObject>
<ApplicationIcon />
<OutputType>Exe</OutputType>
Expand Down
13 changes: 1 addition & 12 deletions src/Downloader.DummyHttpServer/HttpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
using Microsoft.Extensions.Hosting;
using System;
using System.Linq;
using System.Net;
using System.Threading;
using System.Threading.Tasks;

namespace Downloader.DummyHttpServer;

public static class HttpServer
public class HttpServer
{
private static IMemoryCache _cache = new MemoryCache(new MemoryCacheOptions());
private static IWebHost Server;
Expand Down Expand Up @@ -74,14 +73,4 @@ public static IWebHost CreateHostBuilder(int port)

return host.Build();
}

public static IWebHost CreateKestrelBuilder(int port)
{
IWebHost webHost = new WebHostBuilder()
.UseKestrel(options => options.Listen(IPAddress.Loopback, port)) // dynamic port
.UseStartup<Startup>()
.Build();

return webHost;
}
}

0 comments on commit 554b5fe

Please sign in to comment.