Skip to content

Commit d8324ba

Browse files
committed
Updated to make the hangfire dashboard respect the admin directory name.
1 parent e1138fb commit d8324ba

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

src/Cofoundry.Plugins.BackgroundTasks.Hangfire/Startup/HangfireServerInitializer.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Hangfire;
1+
using Cofoundry.Core;
2+
using Cofoundry.Domain;
3+
using Hangfire;
24
using Hangfire.Dashboard;
35
using Microsoft.AspNetCore.Builder;
46
using System;
@@ -16,12 +18,15 @@ namespace Cofoundry.Plugins.BackgroundTasks.Hangfire
1618
public class HangfireServerInitializer : IHangfireServerInitializer
1719
{
1820
private readonly HangfireSettings _hangfireSettings;
21+
private readonly AdminSettings _adminSettings;
1922

2023
public HangfireServerInitializer(
21-
HangfireSettings hangfireSettings
24+
HangfireSettings hangfireSettings,
25+
AdminSettings adminSettings
2226
)
2327
{
2428
_hangfireSettings = hangfireSettings;
29+
_adminSettings = adminSettings;
2530
}
2631

2732
public void Initialize(IApplicationBuilder app)
@@ -31,12 +36,13 @@ public void Initialize(IApplicationBuilder app)
3136

3237
app.UseHangfireServer();
3338

34-
if (_hangfireSettings.EnableHangfireDashboard)
39+
if (_hangfireSettings.EnableHangfireDashboard && !_adminSettings.Disabled)
3540
{
36-
app.UseHangfireDashboard("/admin/hangfire", new DashboardOptions
41+
var adminPath = FilePathHelper.CombineVirtualPath(_adminSettings.DirectoryName, "hangfire");
42+
app.UseHangfireDashboard(adminPath, new DashboardOptions
3743
{
3844
Authorization = new IDashboardAuthorizationFilter[] { new HangfireDashboardAuthorizationFilter() },
39-
AppPath = "/admin"
45+
AppPath = "/" + _adminSettings.DirectoryName
4046
});
4147
}
4248
}

src/HangfireSample/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
"Cofoundry": {
1010
"Database:ConnectionString": "Server=.\\sqlexpress;Database=HangfireSample;Integrated Security=True;MultipleActiveResultSets=True",
11+
1112
"Plugins": {
1213
"Hangfire": {
1314
"Disabled": false,
14-
"EnableHangfireDashboard": true
15+
"EnableHangfireDashboard": true
1516
}
1617
}
1718
}

0 commit comments

Comments
 (0)