From bbfc6f2a6d3a1055e86e54d03b4e5a00d12f5c54 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 31 Jan 2026 23:08:47 +0900 Subject: [PATCH 1/4] Refactor IApiEndpoint and update ResourceServer usage Expanded the IApiEndpoint interface to support advanced routing with a new CanHandle overload and improved documentation. Renamed internal variables in ResourceServer from _tools to _apis to better reflect their purpose and updated all related logic accordingly. --- .../WelsonJS.Launcher/IApiEndpoint.cs | 52 +++++++++++++++---- .../WelsonJS.Launcher/ResourceServer.cs | 26 +++++----- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs b/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs index 6633774..07ccc62 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/IApiEndpoint.cs @@ -1,4 +1,4 @@ -// IResourceTool.cs +// IApiEndpoint.cs // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: 2025 Catswords OSS and WelsonJS Contributors // https://github.com/gnh1201/welsonjs @@ -9,22 +9,56 @@ using System.Threading.Tasks; namespace WelsonJS.Launcher { /// - /// Defines a contract for resource tools that can handle specific HTTP requests. + /// Defines a contract for API endpoints that can selectively handle incoming HTTP requests. /// public interface IApiEndpoint { /// - /// Determines whether this tool can handle the specified path. + /// Determines whether this endpoint can handle a request + /// based solely on the request path. /// - /// The request path to check. - /// True if this tool can handle the request; otherwise, false. + /// + /// 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); + /// - /// Asynchronously processes the HTTP request for the specified path. + /// Determines whether this endpoint can handle the given HTTP request + /// using the full . /// - /// The HTTP listener context containing request and response objects. - /// The request path to handle. - /// A task representing the asynchronous operation. + /// + /// This overload allows more advanced routing decisions based on + /// HTTP method, headers, query parameters, authentication state, + /// or other contextual information. + /// + /// + /// The HTTP listener context containing request and connection details. + /// + /// + /// true if this endpoint can process the request; + /// otherwise, false. + /// + bool CanHandle(HttpListenerContext context); + + /// + /// Asynchronously processes the HTTP request handled by this endpoint. + /// + /// + /// The HTTP listener context containing request and response objects. + /// + /// + /// The request path associated with this handler. + /// + /// + /// A task that represents the asynchronous handling operation. + /// Task HandleAsync(HttpListenerContext context, string path); } } \ No newline at end of file diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs index f5055c5..9113dbb 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs @@ -31,7 +31,7 @@ namespace WelsonJS.Launcher private bool _isRunning; private string _prefix; private string _resourceName; - private List _tools = new List(); + private List _apis = new List(); private BlobConfig _blobConfig; private readonly ILog _logger; @@ -66,15 +66,15 @@ namespace WelsonJS.Launcher _logger?.Error($"FetchBlobConfig failed: {t.Exception}"); }, TaskScheduler.Default); - // Add resource tools - _tools.Add(new ResourceTools.Completion(this, _httpClient, _logger)); - _tools.Add(new ResourceTools.Settings(this, _httpClient, _logger)); - _tools.Add(new ResourceTools.ChromiumDevTools(this, _httpClient, _logger)); - _tools.Add(new ResourceTools.DnsQuery(this, _httpClient, _logger)); - _tools.Add(new ResourceTools.IpQuery(this, _httpClient, _logger)); - _tools.Add(new ResourceTools.TwoFactorAuth(this, _httpClient, _logger)); - _tools.Add(new ResourceTools.Whois(this, _httpClient, _logger)); - _tools.Add(new ResourceTools.ImageColorPicker(this, _httpClient, _logger)); + // Add API endpoints + _apis.Add(new ResourceTools.Completion(this, _httpClient, _logger)); + _apis.Add(new ResourceTools.Settings(this, _httpClient, _logger)); + _apis.Add(new ResourceTools.ChromiumDevTools(this, _httpClient, _logger)); + _apis.Add(new ResourceTools.DnsQuery(this, _httpClient, _logger)); + _apis.Add(new ResourceTools.IpQuery(this, _httpClient, _logger)); + _apis.Add(new ResourceTools.TwoFactorAuth(this, _httpClient, _logger)); + _apis.Add(new ResourceTools.Whois(this, _httpClient, _logger)); + _apis.Add(new ResourceTools.ImageColorPicker(this, _httpClient, _logger)); // Register the prefix _listener.Prefixes.Add(prefix); @@ -152,11 +152,11 @@ namespace WelsonJS.Launcher } // Serve from a resource tool - foreach (var tool in _tools) + foreach (var api in _apis) { - if (tool.CanHandle(path)) + if (api.CanHandle(path)) { - await tool.HandleAsync(context, path); + await api.HandleAsync(context, path); return; } } From 741ade67c30f5c3f37393bbd1439661e782eae97 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 31 Jan 2026 23:17:33 +0900 Subject: [PATCH 2/4] Refactor CanHandle to accept HttpListenerContext Updated the IApiEndpoint interface and all implementing endpoints to change the CanHandle method signature to accept both HttpListenerContext and path. This enables more advanced routing decisions based on the full HTTP request context. ResourceServer and all endpoint usages have been updated accordingly. --- .../ApiEndpoints/ChromiumDevTools.cs | 2 +- .../ApiEndpoints/Completion.cs | 2 +- .../ApiEndpoints/DnsQuery.cs | 2 +- .../ApiEndpoints/ImageColorPicker.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/IpQuery.cs | 2 +- .../ApiEndpoints/Settings.cs | 2 +- .../ApiEndpoints/TwoFactorAuth.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/Whois.cs | 2 +- .../WelsonJS.Launcher/IApiEndpoint.cs | 52 +++++++++---------- .../WelsonJS.Launcher/ResourceServer.cs | 2 +- 10 files changed, 35 insertions(+), 35 deletions(-) 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; From c98fcfea100c72e8483bef87b68fbd8ab859a486 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 31 Jan 2026 23:21:53 +0900 Subject: [PATCH 3/4] Add null checks for path in API endpoint handlers Added null checks for the 'path' parameter in CanHandle methods across all API endpoint classes to prevent potential NullReferenceExceptions. Also made the _apis list in ResourceServer readonly and updated a comment for clarity. --- .../WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/Completion.cs | 2 +- WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs | 2 +- WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs | 2 +- WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs | 2 +- WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs | 2 +- WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs | 4 ++-- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs index a12ceb4..551ffd2 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs @@ -31,7 +31,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs index ad305fc..f8cc1e0 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs @@ -40,7 +40,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs index 92add71..257617a 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs @@ -38,7 +38,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs index 4c44d8f..f5d6433 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs @@ -47,7 +47,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs index e6e2892..c97cd1d 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs @@ -44,7 +44,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs index 649f4cb..3c969d4 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs @@ -34,7 +34,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.Equals(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.Equals(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs index d6e1930..1888242 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs @@ -35,7 +35,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs index 3338e3d..a94cfa9 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs @@ -29,7 +29,7 @@ namespace WelsonJS.Launcher.ResourceTools public bool CanHandle(HttpListenerContext context, string path) { - return path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); + return path != null && path.StartsWith(Prefix, StringComparison.OrdinalIgnoreCase); } public async Task HandleAsync(HttpListenerContext context, string path) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs index ef6ae6d..ea66baa 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs @@ -31,7 +31,7 @@ namespace WelsonJS.Launcher private bool _isRunning; private string _prefix; private string _resourceName; - private List _apis = new List(); + private readonly List _apis = new List(); private BlobConfig _blobConfig; private readonly ILog _logger; @@ -151,7 +151,7 @@ namespace WelsonJS.Launcher return; } - // Serve from a resource tool + // Serve via API endpoints foreach (var api in _apis) { if (api.CanHandle(context, path)) From 7b2a2d49d0f1c886990efd63406bd0a54131b5a7 Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Sat, 31 Jan 2026 23:26:36 +0900 Subject: [PATCH 4/4] Move API endpoints to ApiEndpoints namespace Refactored all API endpoint classes from the ResourceTools namespace to the ApiEndpoints namespace for improved clarity and organization. Updated all references in ResourceServer to use the new namespace. --- .../ApiEndpoints/ChromiumDevTools.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/Completion.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs | 2 +- .../ApiEndpoints/ImageColorPicker.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/IpQuery.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/Settings.cs | 2 +- .../ApiEndpoints/TwoFactorAuth.cs | 2 +- .../WelsonJS.Launcher/ApiEndpoints/Whois.cs | 2 +- .../WelsonJS.Launcher/ResourceServer.cs | 16 ++++++++-------- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs index 551ffd2..ecd3e25 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ChromiumDevTools.cs @@ -11,7 +11,7 @@ using System.Net.Http; using System.Security; using System.Threading.Tasks; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { public class ChromiumDevTools : IApiEndpoint { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs index f8cc1e0..291db13 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Completion.cs @@ -16,7 +16,7 @@ using System.Net.Http; using System.Collections.Concurrent; using log4net; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { public class Completion : IApiEndpoint { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs index 257617a..4035c49 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/DnsQuery.cs @@ -13,7 +13,7 @@ using System.Net.Sockets; using System.Text; using System.Threading.Tasks; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { public class DnsQuery : IApiEndpoint { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs index f5d6433..a75ef85 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/ImageColorPicker.cs @@ -14,7 +14,7 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { /// /// POST image-color-picker/ with a unified JSON body: diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs index c97cd1d..bc338dd 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/IpQuery.cs @@ -25,7 +25,7 @@ using System.Threading.Tasks; using System.Web; using System.Xml.Linq; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { public class IpQuery : IApiEndpoint { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs index 3c969d4..73409cc 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Settings.cs @@ -15,7 +15,7 @@ using System.Resources; using System.Threading.Tasks; using System.Xml.Linq; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { public class Settings : IApiEndpoint { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs index 1888242..555ccdb 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/TwoFactorAuth.cs @@ -14,7 +14,7 @@ using System.Security.Cryptography; using System.Text; using System.Threading.Tasks; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { public class TwoFactorAuth : IApiEndpoint { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs index a94cfa9..06c1259 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ApiEndpoints/Whois.cs @@ -10,7 +10,7 @@ using System.Net.Http; using System.Text; using System.Threading.Tasks; -namespace WelsonJS.Launcher.ResourceTools +namespace WelsonJS.Launcher.ApiEndpoints { public class Whois : IApiEndpoint { diff --git a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs index ea66baa..2a83aef 100644 --- a/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs +++ b/WelsonJS.Augmented/WelsonJS.Launcher/ResourceServer.cs @@ -67,14 +67,14 @@ namespace WelsonJS.Launcher }, TaskScheduler.Default); // Add API endpoints - _apis.Add(new ResourceTools.Completion(this, _httpClient, _logger)); - _apis.Add(new ResourceTools.Settings(this, _httpClient, _logger)); - _apis.Add(new ResourceTools.ChromiumDevTools(this, _httpClient, _logger)); - _apis.Add(new ResourceTools.DnsQuery(this, _httpClient, _logger)); - _apis.Add(new ResourceTools.IpQuery(this, _httpClient, _logger)); - _apis.Add(new ResourceTools.TwoFactorAuth(this, _httpClient, _logger)); - _apis.Add(new ResourceTools.Whois(this, _httpClient, _logger)); - _apis.Add(new ResourceTools.ImageColorPicker(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.Completion(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.Settings(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.ChromiumDevTools(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.DnsQuery(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.IpQuery(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.TwoFactorAuth(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.Whois(this, _httpClient, _logger)); + _apis.Add(new ApiEndpoints.ImageColorPicker(this, _httpClient, _logger)); // Register the prefix _listener.Prefixes.Add(prefix);