Skip to content

Commit

Permalink
Rename MapStaticAssets extension name to MapAbpStaticAssets.
Browse files Browse the repository at this point in the history
  • Loading branch information
maliming committed Sep 24, 2024
1 parent c873b18 commit 0f34f6d
Show file tree
Hide file tree
Showing 37 changed files with 64 additions and 6,240 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,27 +125,43 @@ public static IApplicationBuilder UseDynamicClaims(this IApplicationBuilder app)
return app.UseMiddleware<AbpDynamicClaimsMiddleware>();
}

public static StaticAssetsEndpointConventionBuilder MapStaticAssets(this IApplicationBuilder app, string? staticAssetsManifestPath = null)
/// <summary>
/// MapAbpStaticAssets is used to serve the files from the abp virtual file system embedded resources(js/css) and call the MapStaticAssets.
/// </summary>
public static StaticAssetsEndpointConventionBuilder MapAbpStaticAssets(this WebApplication app, string? staticAssetsManifestPath = null)
{
return app.As<IApplicationBuilder>().MapAbpStaticAssets(staticAssetsManifestPath);
}

/// <summary>
/// MapAbpStaticAssets is used to serve the files from the abp virtual file system embedded resources(js/css) and call the MapStaticAssets.
/// </summary>
public static StaticAssetsEndpointConventionBuilder MapAbpStaticAssets(this IApplicationBuilder app, string? staticAssetsManifestPath = null)
{
if (app is not IEndpointRouteBuilder endpoints)
{
throw new AbpException("The app(IApplicationBuilder) is not an IEndpointRouteBuilder.");
}

var contentTypeProvider = endpoints.ServiceProvider.GetRequiredService<AbpFileExtensionContentTypeProvider>();
var webContentFileProvider = new WebContentFileProvider(
endpoints.ServiceProvider.GetRequiredService<IVirtualFileProvider>(),
null,
endpoints.ServiceProvider.GetRequiredService<IOptions<AbpAspNetCoreContentOptions>>()
);
app.UseVirtualStaticFiles();

app.UseStaticFiles(new StaticFileOptions()
return endpoints.MapStaticAssets(staticAssetsManifestPath);
}

/// <summary>
/// This static file provider is used to serve the files from the abp virtual file system embedded resources(js/css).
/// It will not serve the files from the application's wwwroot folder.
/// </summary>
public static IApplicationBuilder UseVirtualStaticFiles(this IApplicationBuilder app)
{
return app.UseStaticFiles(new StaticFileOptions()
{
ContentTypeProvider = contentTypeProvider,
FileProvider = webContentFileProvider
ContentTypeProvider = app.ApplicationServices.GetRequiredService<AbpFileExtensionContentTypeProvider>(),
FileProvider = new WebContentFileProvider(
app.ApplicationServices.GetRequiredService<IVirtualFileProvider>(),
null,
app.ApplicationServices.GetRequiredService<IOptions<AbpAspNetCoreContentOptions>>()
)
});

var result = endpoints.MapStaticAssets(staticAssetsManifestPath);
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
}

app.UseRouting();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseConfiguredEndpoints();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseDeveloperExceptionPage();
}

app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseConfiguredEndpoints();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseErrorPage();
}

app.MapStaticAssets();
app.MapAbpStaticAssets();

app.UseRouting();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
app.UseDeveloperExceptionPage();
}

app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseConfiguredEndpoints();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex

app.UseHttpsRedirection();
app.UseCorrelationId();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex

app.UseHttpsRedirection();
app.UseCorrelationId();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseCors(DefaultCorsPolicyName);
app.UseAuthentication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
}

app.UseHttpsRedirection();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseAuthentication();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
}

app.UseHttpsRedirection();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseAuthentication();

Expand Down
2 changes: 1 addition & 1 deletion modules/docs/app/VoloDocs.Web/VoloDocsWebModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
var app = context.GetApplicationBuilder();
var env = context.GetEnvironment();

app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
}

app.UseHttpsRedirection();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
Expand Down
2 changes: 1 addition & 1 deletion modules/openiddict/app/OpenIddict.Demo.Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
}

app.UseHttpsRedirection();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseCors();
app.UseAuthentication();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
}

app.UseHttpsRedirection();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex
{
var app = context.GetApplicationBuilder();

app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseAbpRequestLocalization();
app.UseConfiguredEndpoints();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public override void OnApplicationInitialization(ApplicationInitializationContex

app.UseHttpsRedirection();
app.UseCorrelationId();
app.MapStaticAssets();
app.MapAbpStaticAssets();
app.UseRouting();
app.UseAuthentication();
app.UseAbpOpenIddictValidation();
Expand Down
Loading

0 comments on commit 0f34f6d

Please sign in to comment.