Skip to content

Comments

Introduce formatter registry to eliminate formatResponse() function#426

Merged
ryanfowler merged 1 commit intomainfrom
formatter-registry
Feb 13, 2026
Merged

Introduce formatter registry to eliminate formatResponse() function#426
ryanfowler merged 1 commit intomainfrom
formatter-registry

Conversation

@ryanfowler
Copy link
Owner

Move ContentType enum, GetContentType(), and SniffContentType() into the format package and add a registry pattern with BufferedFormatter and StreamingFormatter types. Each formatter self-registers via init(), replacing the hardcoded switch statements in formatResponse() with registry lookups. Special cases (gRPC streaming, Protobuf with descriptor, Image rendering) remain inline due to extra context needs.

Move ContentType enum, GetContentType(), and SniffContentType() into the
format package and add a registry pattern with BufferedFormatter and
StreamingFormatter types. Each formatter self-registers via init(),
replacing the hardcoded switch statements in formatResponse() with
registry lookups. Special cases (gRPC streaming, Protobuf with
descriptor, Image rendering) remain inline due to extra context needs.
@ryanfowler ryanfowler changed the title Introduce formatter registry to eliminate formatResponse() god function Introduce formatter registry to eliminate formatResponse() function Feb 13, 2026
@ryanfowler ryanfowler merged commit a7b8c54 into main Feb 13, 2026
10 checks passed
@ryanfowler ryanfowler deleted the formatter-registry branch February 13, 2026 02:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant