Path: redb-route/redb.Route.DataFormats.Avro/AvroRouteDefinitionExtensions.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.DataFormats.Avro/AvroRouteDefinitionExtensions.cs
----
using redb.Route.Abstractions;
using redb.Route.Extensions;
namespace redb.Route.DataFormats.Avro;
/// DSL and registration sugar for .
public static class AvroRouteDefinitionExtensions
{
/// Marshals the body to Avro binary.
public static IRouteDefinition MarshalAvro(this IRouteDefinition route, Action? configure = null)
=> route.Marshal(new AvroDataFormat(Build(configure)));
/// Unmarshals Avro binary to .
public static IRouteDefinition UnmarshalAvro(this IRouteDefinition route, Action? configure = null)
=> route.Unmarshal(new AvroDataFormat(Build(configure)));
/// Registers Avro as application/avro on the context.
public static IRouteContext AddAvroDataFormat(this IRouteContext context, Action? configure = null)
=> context.AddDataFormat(new AvroDataFormat(Build(configure)), AvroDataFormat.Name);
/// DI form of .
public static RedbRouteBuilder AddAvroDataFormat(this RedbRouteBuilder builder, Action? configure = null)
=> builder.AddDataFormat(new AvroDataFormat(Build(configure)), AvroDataFormat.Name);
private static AvroDataFormatOptions Build(Action? configure)
{
var options = new AvroDataFormatOptions();
configure?.Invoke(options);
return options;
}
}