2.2 KiB
Mvc
⚠️ TEMPORARILY DISABLED — formatter sources block-commented (
/* ... */) andMicrosoft.AspNetCore.AppFrameworkReference removed fromAyCode.Services.csproj(downstream net10.0 Hybrid client conflict onMicrosoft.AspNetCore.Mvcnamespace). Re-enable when split into a separate NuGet package / solution. Description below documents the intended state.
ASP.NET Core MVC formatters for AcBinary wire format. Standard MVC pipeline integration — works with both controller-based MVC and Minimal API.
Topic docs:
AyCode.Services/docs/MVC/README.md— media type, request/response flow, configuration, ProblemDetails error model. Binary serializer:../../AyCode.Core/AyCode.Core/docs/BINARY/README.md
Key Files
AcBinaryInputFormatter.cs— Reads request body viaPipeReader.Create(Request.Body), drains chunks intoAsyncPipeReaderInputon the calling thread while a backgroundTask.Rundeserializes incrementally viaAcBinaryDeserializer.Deserialize(input, ModelType, opts). ProblemDetails error flow on failure (ModelState.TryAddModelError→ 400 +application/problem+json). Cancellation honorsHttpContext.RequestAborted.AcBinaryOutputFormatter.cs— WrapsResponse.BodyasPipeWriter, callsAcBinarySerializer.SerializeChunked(Object, ObjectType, writer, opts)(raw mode — pure AcBinary bytes, no per-chunk framing).pipeWriter.CompleteAsync()in finally.AcBinaryMvcBuilderExtensions.cs—IMvcBuilder.AddAcBinaryFormatters(...)+IMvcCoreBuilder.AddAcBinaryFormatters(...). Inserts both formatters at index 0 ofMvcOptions.InputFormatters/OutputFormattersso AcBinary is preferred when the client'sAcceptheader allows.
Media Type
application/vnd.acbinary (vendor tree). Configurable per-instance via SupportedMediaTypes.Add(...) if a different type is needed.
Layering
The formatter owns the transport-specific drain-loop (PipeReader.ReadAsync → input.Feed). The serializer surface ends at AsyncPipeReaderInput — AcBinaryDeserializer itself does not know about PipeReader. This mirrors the SignalR pattern (AcBinaryHubProtocol.TryParseChunkData does the same state.Buffer.Write(span)-loop).