Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/SimpleW/Router.cs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,8 @@ public void MapFallback(Delegate handler) {

#region not found

private static readonly HttpRouteExecutor _notFoundExecutor = RouteExecutorFactory.Create(static (HttpSession s) => s.Response.Status(404).Text("Not Found").SendAsync());
// a plain HttpRouteExecutor rather than RouteExecutorFactory.Create() : a Delegate handler is compiled from an expression tree, which fails under NativeAOT
private static readonly HttpRouteExecutor _notFoundExecutor = static (session, _) => session.Response.Status(404).Text("Not Found").SendAsync();

#endregion not found

Expand Down
5 changes: 3 additions & 2 deletions src/SimpleW/modules/ServerSentEventsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ public ServerSentEventsModule(ServerSentEventsOptions options) {
/// <param name="server"></param>
/// <exception cref="InvalidOperationException"></exception>
public void Install(SimpleWServer server) {
// map an HttpRouteExecutor rather than a Delegate : a Delegate handler is compiled from an expression tree, which fails under NativeAOT
// accept prefix
server.MapGet(_options.Prefix, (HttpSession session) => HandlerAsync(session));
server.Router.Map("GET", _options.Prefix, (session, _) => HandlerAsync(session));
// accept prefix wildcard as fallback (but will enforce exact match)
server.MapGet(_options.PrefixWildCard, (HttpSession session) => HandlerAsync(session));
server.Router.Map("GET", _options.PrefixWildCard, (session, _) => HandlerAsync(session));

_log.Info($"installed with prefix {_options.Prefix}");
}
Expand Down
5 changes: 3 additions & 2 deletions src/SimpleW/modules/StaticFilesModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,9 @@ public void Install(SimpleWServer server) {
}

// map GET + HEAD
server.MapGet(_options.PrefixWildCard, (HttpSession session) => HandlerAsync(session));
server.Map("HEAD", _options.PrefixWildCard, (HttpSession session) => HandlerAsync(session));
// map an HttpRouteExecutor rather than a Delegate : a Delegate handler is compiled from an expression tree, which fails under NativeAOT
server.Router.Map("GET", _options.PrefixWildCard, (session, _) => HandlerAsync(session));
server.Router.Map("HEAD", _options.PrefixWildCard, (session, _) => HandlerAsync(session));

_log.Info($"installed with prefix {_options.Prefix}");
}
Expand Down
5 changes: 3 additions & 2 deletions src/SimpleW/modules/WebSocketModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,11 @@ public WebSocketModule(WebSocketOptions options) {
/// <param name="server"></param>
/// <exception cref="InvalidOperationException"></exception>
public void Install(SimpleWServer server) {
// map an HttpRouteExecutor rather than a Delegate : a Delegate handler is compiled from an expression tree, which fails under NativeAOT
// accept prefix
server.MapGet(_options.Prefix, (HttpSession session) => HandlerAsync(session));
server.Router.Map("GET", _options.Prefix, (session, _) => HandlerAsync(session));
// accept prefix wildcard as fallback (but will enforce exact match)
server.MapGet(_options.PrefixWildCard, (HttpSession session) => HandlerAsync(session));
server.Router.Map("GET", _options.PrefixWildCard, (session, _) => HandlerAsync(session));

_log.Info($"installed with prefix {_options.Prefix}");
}
Expand Down