using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace ScadaLink.InboundAPI;
///
/// Endpoint filter applied to POST /api/{methodName} that enforces two
/// cross-cutting guards before the request handler runs:
///
///
///
/// InboundAPI-008 — active-node gating. The inbound API is central-active-node-only;
/// a standby node returns HTTP 503 so it never executes method scripts.
///
///
/// InboundAPI-006 — request body size cap. Oversized bodies are rejected with HTTP
/// 413 before being buffered into a JsonDocument.
///
///
///
public sealed class InboundApiEndpointFilter : IEndpointFilter
{
private readonly ILogger _logger;
private readonly InboundApiOptions _options;
public InboundApiEndpointFilter(
ILogger logger,
IOptions options)
{
_logger = logger;
_options = options.Value;
}
public async ValueTask