HtmlResponseRewritingProcessor Pennington.Infrastructure
Single IResponseProcessor that owns the HTML rewriting pipeline. Invokes every registered IHtmlResponseRewriter in Order order, parsing and serializing the shared AngleSharp document exactly once per response.
Before this orchestrator, xref resolution, locale prefixing, and base-URL rewriting each ran as their own IResponseProcessor with its own parse/serialize cycle and its own IBrowsingContext.
Properties
Orderint- Execution order; lower values run earlier in the response pipeline.
Constructors
.ctor
#public HtmlResponseRewritingProcessor(IEnumerable<IHtmlResponseRewriter> rewriters);Initializes the orchestrator with the registered rewriters, ordered by Order.
Parameters
rewritersIEnumerable<IHtmlResponseRewriter>
Methods
ProcessAsync
#public async Task<string> ProcessAsync(string responseBody, HttpContext context);Transforms responseBody and returns the processed body.
Parameters
responseBodystringcontextHttpContext
Returns
Task<string>ShouldProcess
#public bool ShouldProcess(HttpContext context);Returns true when this processor should run for the current request.
Parameters
contextHttpContext
Returns
boolPennington.Infrastructure.HtmlResponseRewritingProcessor
namespace Pennington.Infrastructure;
/// Single IResponseProcessor that owns the HTML rewriting pipeline. Invokes every registered IHtmlResponseRewriter in Order order, parsing and serializing the shared AngleSharp document exactly once per response. Before this orchestrator, xref resolution, locale prefixing, and base-URL rewriting each ran as their own IResponseProcessor with its own parse/serialize cycle and its own IBrowsingContext.
public class HtmlResponseRewritingProcessor
{
/// Initializes the orchestrator with the registered rewriters, ordered by Order.
public HtmlResponseRewritingProcessor(IEnumerable<IHtmlResponseRewriter> rewriters);
/// Execution order; lower values run earlier in the response pipeline.
public int Order => 10;
/// Transforms responseBody and returns the processed body.
public async Task<string> ProcessAsync(string responseBody, HttpContext context);
/// Returns true when this processor should run for the current request.
public bool ShouldProcess(HttpContext context);
}