Skip to content

Commit

Permalink
v5 cleanup: Move HTTP requests to resources, file upload/return under…
Browse files Browse the repository at this point in the history
… /_dotvvm/
  • Loading branch information
exyi committed Dec 20, 2024
1 parent 1fff36f commit e0e6167
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static async Task ReturnFileAsync(this IDotvvmRequestContext context, Str
var downloadAttribute = attachmentDispositionType == "inline" ? null : fileName;

var generatedFileId = await returnedFileStorage.StoreFileAsync(stream, metadata).ConfigureAwait(false);
context.SetRedirectResponse(context.TranslateVirtualPath("~/dotvvmReturnedFile?id=" + generatedFileId), downloadName: downloadAttribute);
context.SetRedirectResponse(context.TranslateVirtualPath("~/_dotvvm/returnedFile?id=" + generatedFileId), downloadName: downloadAttribute);
throw new DotvvmInterruptRequestExecutionException(InterruptReason.ReturnFile, fileName);
}

Expand Down
8 changes: 2 additions & 6 deletions src/Framework/Framework/Hosting/HostingConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,9 @@ public class HostingConstants
public const string DotvvmRequestContextKey = "dotvvm.requestContext";
public const string DotvvmIsErrorHandlingKey = "dotvvm.isErrorHandling";

public const string GlobalizeCultureUrlPath = "dotvvmGlobalizeCulture";
public const string GlobalizeCultureUrlIdParameter = "id";
public const string ResourceRouteName = "dotvvmResource";
public const string ResourceHandlerUrl = "~/dotvvmEmbeddedResource?name={0}&assembly={1}";
public const string ResourceHandlerMatchUrl = "dotvvmEmbeddedResource";

public const string FileUploadHandlerMatchUrl = "dotvvmFileUpload";
public const string ResourceRouteName = "_dotvvm/resource";
public const string FileUploadHandlerMatchUrl = "_dotvvm/fileUpload";
public const string CsrfTokenMatchUrl = "___dotvvm-create-csrf-token___";

public const string SpaContentPlaceHolderHeaderName = "X-DotVVM-SpaContentPlaceHolder";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task<bool> Handle(IDotvvmRequestContext request)
{
var url = DotvvmMiddlewareBase.GetCleanRequestUrl(request.HttpContext);

if (url.StartsWith("dotvvmReturnedFile", StringComparison.Ordinal))
if (url.StartsWith("_dotvvm/returnedFile", StringComparison.Ordinal))
{
await ValidateSecFetch(request);
await RenderReturnedFile(request.HttpContext, request.Services.GetRequiredService<IReturnedFileStorage>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class DotvvmRoutingMiddleware : IMiddleware
/// <see href="https://developers.google.com/webmasters/ajax-crawling/docs/getting-started"/>
private static bool TryParseGooglebotHashbangEscapedFragment(string queryString, [System.Diagnostics.CodeAnalysis.MaybeNullWhen(false)] out string url)
{
// TODO: remove, does not work
if (queryString?.StartsWith(GooglebotHashbangEscapedFragment, StringComparison.Ordinal) == true)
{
url = queryString.Substring(GooglebotHashbangEscapedFragment.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task GetFileCustom()
var stream = new MemoryStream("test custom file"u8.ToArray());
var generatedFileId = await returnedFileStorage.StoreFileAsync(stream, metadata).ConfigureAwait(false);

var url = Context.TranslateVirtualPath("~/dotvvmReturnedFile?id=" + generatedFileId);
var url = Context.TranslateVirtualPath("~/_dotvvm/returnedFile?id=" + generatedFileId);
Context.RedirectToUrl(url);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@


<!-- Resource knockout of type ScriptResource. Pointing to EmbeddedResourceLocation. -->
<script src=/dotvvmResource/knockout/knockout defer></script>
<script src=/_dotvvm/resource/knockout/knockout defer></script>
<!-- Resource dotvvm.internal of type ScriptModuleResource. Pointing to EmbeddedResourceLocation. -->
<script src=/dotvvmResource/dotvvm--internal/dotvvm--internal type=module></script>
<script src="/_dotvvm/resource/dotvvm--internal/dotvvm--internal" type=module></script>
<!-- Resource dotvvm of type InlineScriptResource. -->

<!-- Resource dotvvm.debug of type ScriptResource. Pointing to EmbeddedResourceLocation. -->
<script src=/dotvvmResource/dotvvm--debug/dotvvm--debug defer></script>
<script src=/_dotvvm/resource/dotvvm--debug/dotvvm--debug defer></script>
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<span class="dotvvm-upload-button" data-bind="visible: !IsBusy()">
<a href="javascript:;" onclick="dotvvm.fileUpload.showUploadDialog(this); return false;">Upload</a>
</span>
<input data-bind="dotvvm-FileUpload: {&quot;url&quot;:&quot;/dotvvmFileUpload?multiple=true&quot;}" multiple="multiple" style="display:none" type="file">
<input data-bind="dotvvm-FileUpload: {&quot;url&quot;:&quot;/_dotvvm/fileUpload?multiple=true&quot;}" multiple="multiple" style="display:none" type="file">
<span class="dotvvm-upload-files" data-bind="html: dotvvm.globalize.format(&quot;{0} files&quot;, Files().length)"></span>
<span class="dotvvm-upload-progress-wrapper" data-bind="visible: IsBusy">
<span class="dotvvm-upload-progress" data-bind="style: { 'width': (Progress() == -1 ? '50' : Progress()) + '%' }"></span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
<head>

<!-- Resource knockout of type ScriptResource. Pointing to EmbeddedResourceLocation. -->
<script defer="" src="/dotvvmResource/knockout/knockout"></script>
<script defer="" src="/_dotvvm/resource/knockout/knockout"></script>

<!-- Resource dotvvm.internal of type ScriptModuleResource. Pointing to EmbeddedResourceLocation. -->
<script src="/dotvvmResource/dotvvm--internal/dotvvm--internal" type="module"></script>
<script src="/_dotvvm/resource/dotvvm--internal/dotvvm--internal" type="module"></script>

<!-- Resource dotvvm of type InlineScriptResource. -->
<!-- Resource dotvvm.debug of type ScriptResource. Pointing to EmbeddedResourceLocation. -->
<script defer="" src="/dotvvmResource/dotvvm--debug/dotvvm--debug"></script>
<script defer="" src="/_dotvvm/resource/dotvvm--debug/dotvvm--debug"></script>

<!-- Resource viewModule.import.6DLlOTYMqGV5yPAJoz5k_moKDBgEmZ3_HLLQ2zKDo74 of type ViewModuleImportResource. -->
<script type="module">import * as m0 from "/dotvvmResource/myModule/myModule";dotvvm.viewModules.registerMany({"myModule": m0});</script>
<script type="module">import * as m0 from "/_dotvvm/resource/myModule/myModule";dotvvm.viewModules.registerMany({"myModule": m0});</script>

<!-- Resource viewModule.init.6DLlOTYMqGV5yPAJoz5k_moKDBgEmZ3_HLLQ2zKDo74 of type ViewModuleInitResource. -->
<script type="module">dotvvm.events.init.subscribeOnce(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<head>

<!-- Resource knockout of type ScriptResource. Pointing to EmbeddedResourceLocation. -->
<script defer="" src="/dotvvmResource/knockout/knockout"></script>
<script defer="" src="/_dotvvm/resource/knockout/knockout"></script>

<!-- Resource dotvvm.internal of type ScriptModuleResource. Pointing to EmbeddedResourceLocation. -->
<script src="/dotvvmResource/dotvvm--internal/dotvvm--internal" type="module"></script>
<script src="/_dotvvm/resource/dotvvm--internal/dotvvm--internal" type="module"></script>

<!-- Resource dotvvm of type InlineScriptResource. -->
<!-- Resource viewModule.import.lIquTPFe3a42GboPePTmYZ4Xc1S4ok-JXmZud9HUybE of type ViewModuleImportResource. -->
<script type="module">import * as m0 from "/dotvvmResource/controlModule/controlModule";dotvvm.viewModules.registerMany({"controlModule": m0});</script>
<script type="module">import * as m0 from "/_dotvvm/resource/controlModule/controlModule";dotvvm.viewModules.registerMany({"controlModule": m0});</script>

<!-- Resource dotvvm.debug of type ScriptResource. Pointing to EmbeddedResourceLocation. -->
<script defer="" src="/dotvvmResource/dotvvm--debug/dotvvm--debug"></script>
<script defer="" src="/_dotvvm/resource/dotvvm--debug/dotvvm--debug"></script>

<!-- Resource viewModule.import.HIj399FcjVwbyaIvDKFctn7Ghr0UMajY-haUgZypcHs of type ViewModuleImportResource. -->
<script type="module">import * as m0 from "/dotvvmResource/viewModule/viewModule";dotvvm.viewModules.registerMany({"viewModule": m0});</script>
<script type="module">import * as m0 from "/_dotvvm/resource/viewModule/viewModule";dotvvm.viewModules.registerMany({"viewModule": m0});</script>

<!-- Resource viewModule.init.HIj399FcjVwbyaIvDKFctn7Ghr0UMajY-haUgZypcHs of type ViewModuleInitResource. -->
<script type="module">dotvvm.events.init.subscribeOnce(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/Tracing/ApplicationInsights/RequestTelemetryFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private bool CheckIfSend(ITelemetry item)
{
return true;
}
if (request.Url.AbsolutePath.StartsWith("/dotvvmResource") || request.ResponseCode.Equals("404"))
if (request.Url.AbsolutePath.StartsWith("/_dotvvm/resource") || request.ResponseCode.Equals("404"))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static IDotvvmServiceCollection AddMiniProfilerEventTracing(this IDotvvmS
services.Services.AddScoped<IRequestTimingStorage, DotvvmTimingStorage>();

services.Services.Configure((MiniProfilerOptions opt) => {
opt.IgnoredPaths.Add("/dotvvmResource/");
opt.IgnoredPaths.Add("/_dotvvm/");
});

services.Services.Configure((DotvvmConfiguration conf) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static IDotvvmServiceCollection AddMiniProfilerEventTracing(this IDotvvmS

services.Services.Configure((MiniProfilerOptions opt) =>
{
opt.IgnoredPaths.Add("/dotvvmResource/");
opt.IgnoredPaths.Add("/_dotvvm/");
});

services.Services.AddTransient<IConfigureOptions<DotvvmConfiguration>, MiniProfilerSetup>();
Expand Down

0 comments on commit e0e6167

Please sign in to comment.