1
- using Hangfire ;
1
+ using Cofoundry . Core ;
2
+ using Cofoundry . Domain ;
3
+ using Hangfire ;
2
4
using Hangfire . Dashboard ;
3
5
using Microsoft . AspNetCore . Builder ;
4
6
using System ;
@@ -16,12 +18,15 @@ namespace Cofoundry.Plugins.BackgroundTasks.Hangfire
16
18
public class HangfireServerInitializer : IHangfireServerInitializer
17
19
{
18
20
private readonly HangfireSettings _hangfireSettings ;
21
+ private readonly AdminSettings _adminSettings ;
19
22
20
23
public HangfireServerInitializer (
21
- HangfireSettings hangfireSettings
24
+ HangfireSettings hangfireSettings ,
25
+ AdminSettings adminSettings
22
26
)
23
27
{
24
28
_hangfireSettings = hangfireSettings ;
29
+ _adminSettings = adminSettings ;
25
30
}
26
31
27
32
public void Initialize ( IApplicationBuilder app )
@@ -31,12 +36,13 @@ public void Initialize(IApplicationBuilder app)
31
36
32
37
app . UseHangfireServer ( ) ;
33
38
34
- if ( _hangfireSettings . EnableHangfireDashboard )
39
+ if ( _hangfireSettings . EnableHangfireDashboard && ! _adminSettings . Disabled )
35
40
{
36
- app . UseHangfireDashboard ( "/admin/hangfire" , new DashboardOptions
41
+ var adminPath = FilePathHelper . CombineVirtualPath ( _adminSettings . DirectoryName , "hangfire" ) ;
42
+ app . UseHangfireDashboard ( adminPath , new DashboardOptions
37
43
{
38
44
Authorization = new IDashboardAuthorizationFilter [ ] { new HangfireDashboardAuthorizationFilter ( ) } ,
39
- AppPath = "/admin"
45
+ AppPath = "/" + _adminSettings . DirectoryName
40
46
} ) ;
41
47
}
42
48
}
0 commit comments