mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-10 05:36:04 +00:00
Update ResourceServer.cs
This commit is contained in:
parent
2da5051c5b
commit
240a65e61c
|
@ -86,7 +86,6 @@ namespace WelsonJS.Launcher
|
||||||
private void ProcessRequest(HttpListenerContext context)
|
private void ProcessRequest(HttpListenerContext context)
|
||||||
{
|
{
|
||||||
string path = context.Request.Url.AbsolutePath.TrimStart('/');
|
string path = context.Request.Url.AbsolutePath.TrimStart('/');
|
||||||
string prefix;
|
|
||||||
|
|
||||||
// Serve the favicon.ico file
|
// Serve the favicon.ico file
|
||||||
if ("favicon.ico".Equals(path, StringComparison.OrdinalIgnoreCase))
|
if ("favicon.ico".Equals(path, StringComparison.OrdinalIgnoreCase))
|
||||||
|
@ -96,18 +95,18 @@ namespace WelsonJS.Launcher
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve the code completion (word suggestion)
|
// Serve the code completion (word suggestion)
|
||||||
prefix = "completion/";
|
const string completionPrefix = "completion/";
|
||||||
if (path.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
if (path.StartsWith(completionPrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
ServeCompletion(context, path.Substring(prefix.Length));
|
ServeCompletion(context, path.Substring(completionPrefix.Length));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Serve the DevTools Protocol
|
// Serve the DevTools Protocol
|
||||||
prefix = "devtools/";
|
const string devtoolsPrefix = "devtools/";
|
||||||
if (path.StartsWith(prefix, StringComparison.OrdinalIgnoreCase))
|
if (path.StartsWith(devtoolsPrefix, StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
ServeDevTools(context, path.Substring(prefix.Length - 1));
|
ServeDevTools(context, path.Substring(devtoolsPrefix.Length - 1));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,15 +153,17 @@ namespace WelsonJS.Launcher
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
HttpClient client = new HttpClient();
|
using (HttpClient client = new HttpClient())
|
||||||
string url = "http://localhost:9222" + endpoint;
|
{
|
||||||
string data = Task.Run(async () => await client.GetStringAsync(url)).Result;
|
string url = "http://localhost:9222" + endpoint;
|
||||||
|
string data = client.GetStringAsync(url).GetAwaiter().GetResult();
|
||||||
|
|
||||||
ServeResource(context, data, "application/json");
|
ServeResource(context, data, "application/json");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ServeResource(context, $"<error>Failed to process completion request. {ex.Message}</error>", "application/xml", 500);
|
ServeResource(context, $"<error>Failed to process DevTools request. {ex.Message}</error>", "application/xml", 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user