Skip to content

Commit 9b521d4

Browse files
Ammends SignalR docs to be simpier as the umbraco path can not be configured past V9
1 parent c348e52 commit 9b521d4

File tree

1 file changed

+6
-50
lines changed
  • 13/umbraco-cms/implementation/custom-routing

1 file changed

+6
-50
lines changed

13/umbraco-cms/implementation/custom-routing/signalR.md

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -34,53 +34,10 @@ public class TestHub : Hub<ITestHubEvents>
3434
}
3535
```
3636

37-
## Define a custom route
38-
39-
Next up, is defining a custom route. For this, we are going to use a `IAreaRoutes` and the base umbrace backend path so we dont have to reserve another path in the settings.
40-
41-
```csharp
42-
using Microsoft.AspNetCore.Builder;
43-
using Microsoft.Extensions.DependencyInjection;
44-
using Umbraco.Cms.Core.Composing;
45-
using Umbraco.Cms.Core.DependencyInjection;
46-
using Umbraco.Cms.Web.Common.ApplicationBuilder;
47-
using Umbraco.Extensions;
48-
49-
public class TestHubRoutes : IAreaRoutes
50-
{
51-
private readonly IRuntimeState _runtimeState;
52-
private readonly string _umbracoPathSegment;
53-
54-
public TestHubRoutes(
55-
IOptions<GlobalSettings> globalSettings,
56-
IHostingEnvironment hostingEnvironment,
57-
IRuntimeState runtimeState)
58-
{
59-
_runtimeState = runtimeState;
60-
_umbracoPathSegment = globalSettings.Value.GetUmbracoMvcArea(hostingEnvironment);
61-
}
62-
63-
public void CreateRoutes(IEndpointRouteBuilder endpoints)
64-
{
65-
switch (_runtimeState.Level)
66-
{
67-
case Umbraco.Cms.Core.RuntimeLevel.Run:
68-
endpoints.MapHub<TestHub>(GetTestHubRoute());
69-
break;
70-
}
71-
72-
}
73-
74-
public string GetTestHubRoute()
75-
{
76-
return $"/{_umbracoPathSegment}/{nameof(TestHub)}";
77-
}
78-
}
79-
```
8037

8138
### Add the routing to the Umbraco Composer
8239

83-
Last step in the setup is registering our custom route:
40+
The next step in the setup is registering our custom route:
8441

8542
```csharp
8643
using Microsoft.AspNetCore.Builder;
@@ -101,18 +58,17 @@ public class TestHubComposer : IComposer
10158
builder.Services.AddSignalR();
10259
}
10360

104-
// next is adding the routes we defined earlier
105-
builder.Services.AddUnique<TestHubRoutes>();
10661
builder.Services.Configure<UmbracoPipelineOptions>(options =>
10762
{
10863
options.AddFilter(new UmbracoPipelineFilter(
109-
"test",
110-
endpoints: applicationBuilder =>
64+
"Signalr",
65+
endpoints: applicationBuilder =>
11166
{
11267
applicationBuilder.UseEndpoints(e =>
11368
{
114-
var hubRoutes = applicationBuilder.ApplicationServices.GetRequiredService<TestHubRoutes>();
115-
hubRoutes.CreateRoutes(e);
69+
e.MapHub<TestHub>($"/umbraco/{nameof(TestHub)}");
70+
71+
// Register more SignalR hubs or routes here...
11672
});
11773
}
11874
));

0 commit comments

Comments
 (0)