Skip to content

Commit e53f8f2

Browse files
Further progress
1 parent 4daa5a3 commit e53f8f2

5 files changed

Lines changed: 22 additions & 8 deletions

File tree

Adapters/WiredIO/Adapter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ public static void Map(this WiredApp<Http11Context> app, string path, IHandlerBu
3535
public static void Map(this WiredApp<Http11Context> app, string path, IHandler handler, IServerCompanion? companion = null)
3636
=> app.Map(path + "/{*any}", async context => await Bridge.MapAsync(context, handler, companion: companion, registeredPath: path));
3737

38+
public static void BuildPipeline(this WiredApp<Http11Context> app, IHandlerBuilder handler, IServer server)
39+
=> app.BuildPipeline(handler, server);
40+
41+
public static void BuildPipeline(this WiredApp<Http11Context> app, IHandler handler, IServer server)
42+
=> app.BuildPipeline(new List<Func<Http11Context, Func<Http11Context, Task>, Task>>(), context => Bridge.MapAsync(context, handler, server));
43+
3844
/// <summary>
3945
/// Enables default features on the given handler. This should be used on the
4046
/// outer-most handler only.

Adapters/WiredIO/Mapping/Bridge.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
using GenHTTP.Api.Infrastructure;
66
using GenHTTP.Api.Protocol;
77

8+
using Wired.IO.Http11.Context;
9+
810
namespace GenHTTP.Adapters.WiredIO.Mapping;
911

1012
public static class Bridge
1113
{
1214

13-
public static async ValueTask MapAsync(HttpContext context, IHandler handler, IServer? server = null, IServerCompanion? companion = null, string? registeredPath = null)
15+
public static async ValueTask MapAsync(Http11Context context, IHandler handler, IServer? server = null, IServerCompanion? companion = null, string? registeredPath = null)
1416
{
1517
var actualServer = server ?? new ImplicitServer(handler, companion);
1618

Adapters/WiredIO/Types/Query.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections;
22
using GenHTTP.Api.Protocol;
3+
using Wired.IO.Http11.Context;
34

45
namespace GenHTTP.Adapters.WiredIO.Types;
56

@@ -42,13 +43,13 @@ public IEnumerable<string> Values
4243
}
4344
}
4445

45-
private HttpRequest Request { get; }
46+
private Http11Context Request { get; }
4647

4748
#endregion
4849

4950
#region Initialization
5051

51-
public Query(HttpRequest request)
52+
public Query(Http11Context request)
5253
{
5354
Request = request;
5455
}

Adapters/WiredIO/Types/Request.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22
using GenHTTP.Api.Protocol;
33
using GenHTTP.Api.Routing;
44
using GenHTTP.Engine.Shared.Types;
5+
6+
using Wired.IO.Http11.Context;
7+
58
using HttpProtocol = GenHTTP.Api.Protocol.HttpProtocol;
69

10+
using WiredRequest = Wired.IO.Http11.Request.IRequest;
11+
712
namespace GenHTTP.Adapters.WiredIO.Types;
813

914
public sealed class Request : IRequest
@@ -70,18 +75,18 @@ public IHeaderCollection Headers
7075

7176
public FlexibleContentType? ContentType => (Context.ContentType != null) ? new(Context.ContentType) : null;
7277

73-
private HttpRequest Context { get; }
78+
private WiredRequest Context { get; }
7479

7580
#endregion
7681

7782
#region Initialization
7883

79-
public Request(IServer server, HttpContext context)
84+
public Request(IServer server, Http11Context context)
8085
{
8186
Server = server;
8287
Context = context.Request;
8388

84-
ProtocolType = Context.Protocol switch
89+
ProtocolType = Context.ConnectionType switch
8590
{
8691
"HTTP/1.0" => HttpProtocol.Http10,
8792
"HTTP/1.1" => HttpProtocol.Http11,

Engine/WiredIO/Hosting/WiredServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using System.Net.Security;
33
using System.Reflection;
44
using System.Security.Cryptography.X509Certificates;
5-
5+
using GenHTTP.Adapters.WiredIO;
66
using GenHTTP.Api.Content;
77
using GenHTTP.Api.Infrastructure;
88
using GenHTTP.Engine.Shared.Infrastructure;
@@ -73,7 +73,7 @@ private WiredApp<Http11Context> Spawn(Action<Builder<WiredHttp11, Http11Context>
7373

7474
var app = builder.Build();
7575

76-
app.Run(); // todo: adapter goes here (app.BuildPipeline)
76+
app.BuildPipeline(Handler, this);
7777

7878
applicationHook?.Invoke(app);
7979

0 commit comments

Comments
 (0)