-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathImplicitServer.cs
More file actions
58 lines (36 loc) · 1.31 KB
/
ImplicitServer.cs
File metadata and controls
58 lines (36 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System.Runtime.InteropServices;
using GenHTTP.Api.Content;
using GenHTTP.Api.Infrastructure;
using Microsoft.AspNetCore.Http;
namespace GenHTTP.Adapters.AspNetCore.Server;
public sealed class ImplicitServer : IServer
{
#region Get-/Setters
public string Version => RuntimeInformation.FrameworkDescription;
public bool Running { get; }
public bool Development
{
get
{
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
return string.Compare(env, "Development", StringComparison.OrdinalIgnoreCase) == 0;
}
}
public IEndPointCollection EndPoints { get; }
public IServerCompanion? Companion { get; }
public IHandler Handler { get; }
#endregion
#region Initialization
public ImplicitServer(HttpContext context, IHandler handler, IServerCompanion? companion)
{
Handler = handler;
Companion = companion;
EndPoints = new EndpointCollection(context);
Running = true;
}
#endregion
#region Functionality
public ValueTask DisposeAsync() => new();
public ValueTask StartAsync() => throw new InvalidOperationException("Server is managed by ASP.NET Core and cannot be started");
#endregion
}