RunicAssetResults class

Namespace Runic.Assets.AspNetCore in Runic.Assets.AspNetCore 0.23.0

public static class RunicAssetResults

Creates minimal-API results that serve Runic Assets.

Methods

Asset

public static IResult Asset(IAssetSource source, string relativePath, AssetRoutingOptions? routing = null)

Creates a result that serves one asset of source with its manifest-owned HTTP metadata, as RunicAssetEndpointExtensions.WriteAssetAsync does: ETag, Cache-Control, conditional and range requests, and a text/* media type with ; charset=utf-8.

Parameters

source

The source that holds the asset.

relativePath

The request path below the route, such as assets/app.js.

routing

The routing rules and the HTML policy; null uses the defaults.

Returns

The result to return from a minimal-API handler.

Remarks

relativePath resolves with AssetManifest.TryResolveRequestPath when the result runs, against the source's current manifest and routing: an empty path serves the entry point and an extensionless path falls back to it unless routing disables that. A path that does not resolve, or a request other than GET or HEAD, is answered with 404 Not Found. HTML assets carry AssetRoutingOptions.ContentSecurityPolicy when it is set.

app.MapGet("/app/{**path}", (string? path) => RunicAssetResults.Asset(assets, path ?? ""));