router fix
This commit is contained in:
parent
bac1c8368f
commit
f66c0ea706
@ -73,9 +73,8 @@ internal static class Program
|
||||
try
|
||||
{
|
||||
logger.LogInfo(logContext, $"{ctx.Request.HttpMethod} request for {ctx.Request.RawUrl} from {ctx.Request.RemoteEndPoint}");
|
||||
if(router.TryResolve(ctx))
|
||||
logger.LogInfo(logContext, "request handled");
|
||||
else logger.LogInfo(logContext, "request rejected");
|
||||
bool isRequestHandled = router.TryResolve(ctx);
|
||||
logger.LogInfo(logContext, isRequestHandled ? "request handled" : "request rejected");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@ -27,7 +27,9 @@ public class Router
|
||||
else if(ctx.Request.HttpMethod == "GET")
|
||||
{
|
||||
string urlPath = ctx.Request.Url.AbsolutePath;
|
||||
var ext = Path.Extension(urlPath).Str;
|
||||
string ext = urlPath.EndsWith(".js.map")
|
||||
? ".js.map" // extname of '*.js.map' is '.map' so it has to be set explicitely
|
||||
: Path.Extension(urlPath).Str;
|
||||
IOPath filePath;
|
||||
switch (ext)
|
||||
{
|
||||
@ -40,13 +42,13 @@ public class Router
|
||||
ctx.Response.Headers.Set("Content-Type", "text/css");
|
||||
break;
|
||||
case "js":
|
||||
filePath = Path.Concat(publicDirPath, "js", urlPath);
|
||||
case "js.map":
|
||||
case "jsx":
|
||||
case "ts":
|
||||
case "tsx":
|
||||
filePath = Path.Concat(publicDirPath, "scripts", urlPath);
|
||||
ctx.Response.Headers.Set("Content-Type", "text/javascript");
|
||||
break;
|
||||
case "map":
|
||||
if (urlPath.EndsWith(".js.map"))
|
||||
goto case "js";
|
||||
goto default;
|
||||
default:
|
||||
if (urlPath == "/")
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user