Path: redb-route/demo/redb.Route.Demo/Routes/DemoHelpers.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/demo/redb.Route.Demo/Routes/DemoHelpers.cs ---- using System.Text.Encodings.Web; using System.Text.Json; using redb.Route.Abstractions; namespace redb.Route.Demo.Routes; /// /// Pure helpers shared by every demo route builder. /// No state, no DI - just utilities for header access and HTTP response shaping. /// internal static class DemoHelpers { /// Reads a header value as string (null if missing). public static string? GetHeader(IExchange e, string key) => e.In.Headers.TryGetValue(key, out var v) ? v?.ToString() : null; /// Safe substring used by error-handler logging. public static string? Trunc(string? s, int max = 200) => s is null ? null : s[..Math.Min(max, s.Length)]; private static readonly JsonSerializerOptions JsonOpts = new() { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping }; /// Builds the JSON response returned by the main HTTP pipeline. public static string BuildResponse(IExchange e) { return JsonSerializer.Serialize(new { success = true, traceId = GetHeader(e, "traceId"), mode = GetHeader(e, "mode"), stamps = new { rabbit = GetHeader(e, "stamp.rabbit"), amqp = GetHeader(e, "stamp.amqp"), grpc = GetHeader(e, "stamp.grpc"), wmq = GetHeader(e, "stamp.wmq"), vm = GetHeader(e, "stamp.vm"), // Stamps produced by the new flat fluent DSL (Choice + sibling When/Otherwise, // TryCatch with rich Catch log) configured in MainPipelineRoutes.cs. dsl = new { branch = GetHeader(e, "stamp.dsl"), priority = GetHeader(e, "stamp.dsl.priority"), fastTrack = GetHeader(e, "fastTrack"), catchTriggered = GetHeader(e, "stamp.dsl.caught"), }, }, pipeline = "HTTP -> Direct -> RabbitMQ -> AMQP -> gRPC -> WMQ -> DirectVM -> " + "SQL(tx) -> Kafka(tap) -> File(tap) -> VM(tap) -> WMQ(tap)", startedAt = GetHeader(e, "startedAt"), }, JsonOpts); } }