Path: redb-route/redb.Route.As2/As2Endpoint.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.As2/As2Endpoint.cs
----
using Microsoft.Extensions.Logging;
using redb.Route.Abstractions;
using redb.Route.Core;
namespace redb.Route.As2;
///
/// AS2 endpoint. Extends so it gets statistics, health and Tsak
/// visibility for free. Produces an
/// (send) or an (receive server) depending on the DSL side.
///
public sealed class As2Endpoint : EndpointBase
{
/// Logger inherited from the owning component.
internal ILogger? Logger { get; }
/// Typed options, exposed to the consumer/producer.
internal As2EndpointOptions EndpointOptions => Options;
/// The owning route context (for registry lookups), via the component.
internal IRouteContext? Context => (Component as ComponentBase)?.Context;
/// Creates an AS2 endpoint.
public As2Endpoint(EndpointUri uri, As2Component component, As2EndpointOptions options)
: base(uri, component, options)
{
ArgumentNullException.ThrowIfNull(component);
Logger = component.Logger;
// Producer URIs are host-style (as2s://partner/as2 ⇒ path "partner/as2"); reconstruct the partner
// URL from the scheme + path. Consumer URIs are path-style ("/inbound/orders") and skip this.
if (string.IsNullOrEmpty(options.PartnerUrl) && uri.Path.Length > 0 && !uri.Path.StartsWith('/'))
options.PartnerUrl = (options.UseTls ? "https://" : "http://") + uri.Path;
_headerFilter = new EndpointHeaderFilter(this, options.HeaderFilterStrategy);
}
private readonly EndpointHeaderFilter _headerFilter;
///
/// The header filter strategy of this endpoint: the one headerFilterStrategy=#name names, or
/// . A name the registry does not hold fails when the producer or
/// consumer is built.
///
internal IHeaderFilterStrategy HeaderFilterStrategy => _headerFilter.Or(As2HeaderFilterStrategy.Default);
///
public override IProducer CreateProducer() => new As2Producer(this, Options);
///
public override IConsumer CreateConsumer(IProcessor processor) => Options.Mode == As2ReceiveMode.Mdn
? new As2MdnReceiver(this, processor, Options)
: new As2Consumer(this, processor, Options);
}