diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs index d30201a..a12ceb4 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs @@ -29,7 +29,7 @@ namespace WelsonJS.Launcher.ResourceTools _logger = logger; } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs index 5934ebc..ad305fc 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs @@ -38,7 +38,7 @@ namespace WelsonJS.Launcher.ResourceTools Task.Run(async () => await SafeDiscoverAsync(DiscoverFromProgramDirectories)); } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs index 31ee547..92add71 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs @@ -36,7 +36,7 @@ namespace WelsonJS.Launcher.ResourceTools DnsServer = Program.GetAppConfig("DnsServerAddress"); } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs index da801a5..4c44d8f 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs @@ -45,7 +45,7 @@ namespace WelsonJS.Launcher.ResourceTools _logger = logger; } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs index 94d0776..e6e2892 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs @@ -42,7 +42,7 @@ namespace WelsonJS.Launcher.ResourceTools _logger = logger; } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs index c61487a..649f4cb 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs @@ -32,7 +32,7 @@ namespace WelsonJS.Launcher.ResourceTools _logger = logger; } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.Equals(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs index 3acd9f9..d6e1930 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs @@ -33,7 +33,7 @@ namespace WelsonJS.Launcher.ResourceTools _logger = logger; } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs index dcf0e6f..3338e3d 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs @@ -27,7 +27,7 @@ namespace WelsonJS.Launcher.ResourceTools _logger = logger; } - public bool CanHandle(string path) + public bool CanHandle(HttpListenerContext context, string path) { return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs b/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs index 07ccc62..ff00dce 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs @@ -14,47 +14,47 @@ namespace WelsonJS.Launcher public interface IApiEndpoint { /// - /// Determines whether this endpoint can handle a request - /// based solely on the request path. + /// Determines whether this endpoint is able to handle the given HTTP request. /// /// - /// This method is typically used for fast, lightweight routing decisions - /// before inspecting headers, HTTP methods, or request bodies. - /// Implementations should avoid side effects and expensive operations. - /// - /// The normalized request path (e.g. "/api/status"). - /// - /// true if this endpoint is responsible for the given path; - /// otherwise, false. - /// - bool CanHandle(string path); - - /// - /// Determines whether this endpoint can handle the given HTTP request - /// using the full . - /// - /// - /// This overload allows more advanced routing decisions based on - /// HTTP method, headers, query parameters, authentication state, - /// or other contextual information. + /// This method is invoked by the request dispatcher to decide which endpoint + /// should process the incoming request. + /// + /// Implementations may use the provided for fast + /// routing decisions, while the full can be + /// inspected for HTTP method, headers, query parameters, authentication + /// state, or other request-specific information. + /// + /// This method should be free of side effects and must not write to the response. /// /// - /// The HTTP listener context containing request and connection details. + /// The HTTP listener context containing the incoming request details. + /// + /// + /// The normalized request path extracted from the request URL + /// (e.g. "/api/status"). /// /// - /// true if this endpoint can process the request; + /// true if this endpoint is responsible for handling the request; /// otherwise, false. /// - bool CanHandle(HttpListenerContext context); + bool CanHandle(HttpListenerContext context, string path); /// - /// Asynchronously processes the HTTP request handled by this endpoint. + /// Asynchronously handles the HTTP request assigned to this endpoint. /// + /// + /// This method is called only after has returned + /// true for the same request. + /// + /// Implementations are responsible for writing the response and properly + /// terminating the request lifecycle. + /// /// /// The HTTP listener context containing request and response objects. /// /// - /// The request path associated with this handler. + /// The request path associated with this endpoint. /// /// /// A task that represents the asynchronous handling operation. diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs index 9113dbb..ef6ae6d 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs @@ -154,7 +154,7 @@ namespace WelsonJS.Launcher // Serve from a resource tool foreach (var api in _apis) { - if (api.CanHandle(path)) + if (api.CanHandle(context, path)) { await api.HandleAsync(context, path); return;