OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.35k stars 2.37k forks source link

The ScriptsMiddleware(s) should be replaced by endpoints #15629

Open sebastienros opened 5 months ago

sebastienros commented 5 months ago

No need to create a middleware that is impacting the stack size to serve script files. We can register the endpoint routes directly and invoke a delegate.

These methods should also not do string concatenation to render the files. They could precompute the utf8 string (private static ReadOnlySpan<byte> => "value"u8;) and call WriteAsync() for each segment instead.

sebastienros commented 5 months ago

https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Liquid/ScriptsMiddleware.cs

https://github.com/OrchardCMS/OrchardCore/blob/main/src/OrchardCore.Modules/OrchardCore.Facebook/ScriptsMiddleware.cs

Piedone commented 3 months ago

The endpoints in the Content module can serve as examples.