Browse Source

Add pathbase options for dashbaord. #901

master
Savorboard 3 years ago
parent
commit
d4485bd3a2
2 changed files with 11 additions and 2 deletions
  1. +9
    -0
      src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs
  2. +2
    -2
      src/DotNetCore.CAP.Dashboard/UiMiddleware.cs

+ 9
- 0
src/DotNetCore.CAP.Dashboard/CAP.DashboardOptions.cs View File

@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

// ReSharper disable once CheckNamespace

namespace DotNetCore.CAP
{
public class DashboardOptions
@@ -12,6 +13,14 @@ namespace DotNetCore.CAP
StatsPollingInterval = 2000;
}

/// <summary>
/// When behind the proxy, specify the base path to allow spa call prefix.
/// </summary>
public string PathBase { get; set; }

/// <summary>
/// Path prefix to match from url path.
/// </summary>
public string PathMatch { get; set; }

/// <summary>


+ 2
- 2
src/DotNetCore.CAP.Dashboard/UiMiddleware.cs View File

@@ -51,7 +51,7 @@ namespace DotNetCore.CAP.Dashboard
httpContext.Response.StatusCode = StatusCodes.Status401Unauthorized;
return;
}
httpContext.Response.StatusCode = 200;
httpContext.Response.ContentType = "text/html;charset=utf-8";

@@ -60,7 +60,7 @@ namespace DotNetCore.CAP.Dashboard

using var sr = new StreamReader(stream);
var htmlBuilder = new StringBuilder(await sr.ReadToEndAsync());
htmlBuilder.Replace("%(servicePrefix)", _options.PathMatch + "/api");
htmlBuilder.Replace("%(servicePrefix)", _options.PathBase + _options.PathMatch + "/api");
htmlBuilder.Replace("%(pollingInterval)", _options.StatsPollingInterval.ToString());
await httpContext.Response.WriteAsync(htmlBuilder.ToString(), Encoding.UTF8);



Loading…
Cancel
Save