Skip to content

Commit cbcac29

Browse files
committed
Changes based on feedback
1 parent 75fcd3c commit cbcac29

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/ServiceControl/Hosting/Commands/RunCommand.cs

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
namespace ServiceControl.Hosting.Commands
22
{
3-
using System;
4-
using System.IO;
5-
using System.Reflection;
63
using System.Threading.Tasks;
7-
using Infrastructure.WebApi;
84
using Microsoft.AspNetCore.Builder;
9-
using Microsoft.Extensions.FileProviders;
105
using NServiceBus;
116
using Particular.ServiceControl;
127
using Particular.ServiceControl.Hosting;
138
using ServiceBus.Management.Infrastructure.Settings;
149
using ServiceControl;
10+
using ServiceControl.Infrastructure.WebApi;
1511

1612
class RunCommand : AbstractCommand
1713
{
@@ -27,17 +23,9 @@ public override async Task Execute(HostArguments args, Settings settings)
2723
hostBuilder.AddServiceControl(settings, endpointConfiguration);
2824
hostBuilder.AddServiceControlApi();
2925

30-
var servicePulsePath = Path.Combine(AppContext.BaseDirectory, "platform", "servicepulse", "ServicePulse.dll");
31-
var manifestEmbeddedFileProvider = new ManifestEmbeddedFileProvider(Assembly.LoadFrom(servicePulsePath), "wwwroot");
32-
var fileProvider = new CompositeFileProvider(hostBuilder.Environment.WebRootFileProvider, manifestEmbeddedFileProvider);
33-
var defaultFilesOptions = new DefaultFilesOptions { FileProvider = fileProvider };
34-
var staticFileOptions = new StaticFileOptions { FileProvider = fileProvider };
35-
3626
var app = hostBuilder.Build();
37-
app.UseServiceControl()
38-
.UseMiddleware<AppConstantsMiddleware>()
39-
.UseDefaultFiles(defaultFilesOptions)
40-
.UseStaticFiles(staticFileOptions);
27+
app.UseServiceControl();
28+
app.UseServicePulse();
4129

4230
await app.RunAsync(settings.RootUrl);
4331
}

src/ServiceControl/Infrastructure/WebApi/AppConstantsMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public AppConstantsMiddleware(RequestDelegate next)
1919
var settings = ServicePulseSettings.GetFromEnvironmentVariables();
2020
var constants = new
2121
{
22-
default_route = "/dashboard",
22+
default_route = settings.DefaultRoute,
2323
service_control_url = "api/",
2424
monitoring_urls = new[] { settings.MonitoringUri.ToString() },
2525
showPendingRetry = settings.ShowPendingRetry,

src/ServiceControl/WebApplicationExtensions.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
namespace ServiceControl;
22

3+
using System;
4+
using System.IO;
5+
using System.Reflection;
36
using Infrastructure.SignalR;
47
using Infrastructure.WebApi;
58
using Microsoft.AspNetCore.Builder;
69
using Microsoft.AspNetCore.HttpOverrides;
10+
using Microsoft.Extensions.FileProviders;
711

812
public static class WebApplicationExtensions
913
{
@@ -19,4 +23,19 @@ public static IApplicationBuilder UseServiceControl(this WebApplication app)
1923

2024
return app;
2125
}
26+
27+
public static IApplicationBuilder UseServicePulse(this WebApplication app)
28+
{
29+
var servicePulsePath = Path.Combine(AppContext.BaseDirectory, "platform", "servicepulse", "ServicePulse.dll");
30+
var manifestEmbeddedFileProvider = new ManifestEmbeddedFileProvider(Assembly.LoadFrom(servicePulsePath), "wwwroot");
31+
var fileProvider = new CompositeFileProvider(app.Environment.WebRootFileProvider, manifestEmbeddedFileProvider);
32+
var defaultFilesOptions = new DefaultFilesOptions { FileProvider = fileProvider };
33+
var staticFileOptions = new StaticFileOptions { FileProvider = fileProvider };
34+
35+
app.UseMiddleware<AppConstantsMiddleware>()
36+
.UseDefaultFiles(defaultFilesOptions)
37+
.UseStaticFiles(staticFileOptions);
38+
39+
return app;
40+
}
2241
}

0 commit comments

Comments
 (0)