Skip to content

Use protocol media for response negotiation. - #58

Merged
samuel-williams-shopify merged 2 commits into
mainfrom
protocol-media-negotiation
Aug 10, 2026
Merged

Use protocol media for response negotiation.#58
samuel-williams-shopify merged 2 commits into
mainfrom
protocol-media-negotiation

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary.

  • Use Protocol::Media::Map, Type, and Range for response negotiation.
  • Parse and stably order Accept media ranges with Protocol::HTTP::Header::Accept.
  • Preserve request order for equally weighted representations and treat absent or empty Accept headers as accepting any media type.
  • Configure a mutable Responder and compile its handler map when the controller is frozen.
  • Keep wildcard passthrough as an explicit fallback outside the concrete media map.
  • Use Protocol::HTTP::Header::AcceptLanguage for localization and retain locale matching in Utopia::Localization::Locales.
  • Remove the http-accept dependency.
  • Add protocol-media ~> 0.3 and protocol-http ~> 0.70 as runtime dependencies.

Verification.

  • bundle exec sus test/utopia/controller/respond.rb: 16 tests, 37 assertions.
  • bundle exec sus test/utopia/localization.rb: 17 tests, 37 assertions.
  • RuboCop passes for all changed Ruby files.
  • git diff --check passes.

@samuel-williams-shopify
samuel-williams-shopify force-pushed the protocol-media-negotiation branch 2 times, most recently from b934153 to e06d671 Compare August 2, 2026 06:40
@samuel-williams-shopify
samuel-williams-shopify changed the base branch from v3-protocol-application to protocol-application-documentation August 2, 2026 06:40
Base automatically changed from protocol-application-documentation to v3-protocol-application August 2, 2026 06:42
@samuel-williams-shopify
samuel-williams-shopify force-pushed the v3-protocol-application branch 9 times, most recently from 1d4e4e5 to 7507d70 Compare August 2, 2026 12:10
media_types = accept.media_ranges.sort
else
media_types = [Handlers::Passthrough::WILDCARD]
end

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Ooh, opportunity to assign from media_types once, from the if-as-expression.

Base automatically changed from v3-protocol-application to main August 9, 2026 12:05
@samuel-williams-shopify
samuel-williams-shopify force-pushed the protocol-media-negotiation branch 3 times, most recently from e7e10c2 to f8c114d Compare August 10, 2026 00:01
Assisted-By: devx/b3414b50-d642-461b-95a8-8f773c4d087b
Assisted-By: devx/b3414b50-d642-461b-95a8-8f773c4d087b
@samuel-williams-shopify
samuel-williams-shopify merged commit c60b590 into main Aug 10, 2026
22 of 40 checks passed
@samuel-williams-shopify
samuel-williams-shopify deleted the protocol-media-negotiation branch August 10, 2026 01:09
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.

2 participants