Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I have a package that uses SignalR to offer nice progress UI.
porting this to Umbraco 9 - i have seen that you need to register the endpoint for signalR (as perview does here https://github.com/umbraco/Umbraco-CMS/blob/netcore/dev/src/Umbraco.Web.BackOffice/Extensions/UmbracoApplicationBuilder.Preview.cs)
However enpoints are added on the config element in startup.cs - which i don't think you can hook into other than in the code?
app.UseUmbraco() .WithBackOffice() .WithWebsite() .WithEndpoints(u => { u.UseInstallerEndpoints(); u.UseBackOfficeEndpoints(); u.UseWebsiteEndpoints(); });
so progromatically i can add :
u.UseuSyncEndpoints();
but i want to be able to also add this route without requiring the user to alter the startup.cs is that possible? can it be done?
Hi Kevin..
I haven't tested it out, but you should be able to do something like this from the composer:
builder.Services.Configure<UmbracoPipelineOptions>(options => { options.AddFilter(new UmbracoPipelineFilter( "Usync", applicationBuilder => {}, applicationBuilder => {}, applicationBuilder => { // Add your endpoints here.. } )); });
Let me know if it works (Note this syntax is from the latest nightly, maybe the syntax is different in latest alpha )
thanks,
yeah that has worked. 👍 https://github.com/KevinJump/uSync8/blob/core/main/uSync.BackOffice/uSyncBackOfficeBuilderExtensions.cs#L85
I have a secondary issue in that runtime level doesn't appear to then be set when adding the route (i copied this from how the preview hub works.
so i can't do this :
switch (_runtimeState.Level) { case Umbraco.Cms.Core.RuntimeLevel.Run: endpoints.MapHub<SyncHub>(GetuSyncHubRoute()); break; }
https://github.com/KevinJump/uSync8/blob/de4aeb02a41335738c8a8c1af165ad50f350c157/uSync.BackOffice/Hubs/uSyncHubRoutes.cs#L28
However that might not matter in this case - the signalR hub doesn't do anything so adding it when the site isn't setup might be ok (i will check that).
Actually, that last bit was me.
swapping to getting the service via the applicationBuilder not the passed in service .
e.g
var hubRoutes = applicationBuilder.ApplicationServices.GetRequiredService<uSyncHubRoutes>();
means the runtime is set. (guess its an order of execution thing)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
How to add/alter routes/enpoints without changing startup.cs
Hi,
I have a package that uses SignalR to offer nice progress UI.
porting this to Umbraco 9 - i have seen that you need to register the endpoint for signalR (as perview does here https://github.com/umbraco/Umbraco-CMS/blob/netcore/dev/src/Umbraco.Web.BackOffice/Extensions/UmbracoApplicationBuilder.Preview.cs)
However enpoints are added on the config element in startup.cs - which i don't think you can hook into other than in the code?
so progromatically i can add :
but i want to be able to also add this route without requiring the user to alter the startup.cs is that possible? can it be done?
Hi Kevin..
I haven't tested it out, but you should be able to do something like this from the composer:
Let me know if it works (Note this syntax is from the latest nightly, maybe the syntax is different in latest alpha )
thanks,
yeah that has worked. 👍 https://github.com/KevinJump/uSync8/blob/core/main/uSync.BackOffice/uSyncBackOfficeBuilderExtensions.cs#L85
I have a secondary issue in that runtime level doesn't appear to then be set when adding the route (i copied this from how the preview hub works.
so i can't do this :
https://github.com/KevinJump/uSync8/blob/de4aeb02a41335738c8a8c1af165ad50f350c157/uSync.BackOffice/Hubs/uSyncHubRoutes.cs#L28
However that might not matter in this case - the signalR hub doesn't do anything so adding it when the site isn't setup might be ok (i will check that).
Actually, that last bit was me.
swapping to getting the service via the applicationBuilder not the passed in service .
e.g
means the runtime is set. (guess its an order of execution thing)
is working on a reply...