Class FallbackMiddleware

Namespace
Cratis.Arc.Http
Assembly
Cratis.Arc.Core.dll

Middleware for serving a fallback file when no route matches (typically for SPAs).

public class FallbackMiddleware : IHttpRequestMiddleware
Inheritance
FallbackMiddleware
Implements
Inherited Members
Extension Methods

Remarks

Initializes a new instance of the FallbackMiddleware class.

Constructors

FallbackMiddleware(ILogger<FallbackMiddleware>)

Middleware for serving a fallback file when no route matches (typically for SPAs).

public FallbackMiddleware(ILogger<FallbackMiddleware> logger)

Parameters

logger ILogger<FallbackMiddleware>

The logger for the middleware.

Remarks

Initializes a new instance of the FallbackMiddleware class.

Methods

ConfigureFallback(string, string)

Configures the fallback file to serve.

public void ConfigureFallback(string fallbackFilePath, string fileSystemBasePath)

Parameters

fallbackFilePath string

The path to the fallback file, relative to the file system base path.

fileSystemBasePath string

The base file system path.

InvokeAsync(HttpListenerContext, HttpRequestDelegate)

Process an HTTP request.

public Task<bool> InvokeAsync(HttpListenerContext context, HttpRequestDelegate next)

Parameters

context HttpListenerContext

The HTTP listener context.

next HttpRequestDelegate

The next middleware in the pipeline.

Returns

Task<bool>

A task that represents the asynchronous operation, returning true if the request was handled, false otherwise.