Rework CableReady's ActionController::Renderers#260
Merged
Conversation
✅ Deploy Preview for cableready ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
if you provide it a string or already call .dispatch in the controller it would fail
operations ActionController renderer in favor of cable_readyActionController::Renderers
hopsoft
approved these changes
Mar 10, 2023
| Mime::Type.register "application/vnd.cable-ready.json", :cable_ready | ||
| ActionController::Renderers.add :cable_ready do |operations, options| | ||
| response.content_type ||= Mime[:cable_ready] | ||
| response.headers["X-Cable-Ready-Version"] = CableReady::VERSION |
Contributor
There was a problem hiding this comment.
The addition of the version header will be helpful.
jibees
added a commit
to jibees/mrujs
that referenced
this pull request
Mar 30, 2023
Since stimulusreflex/cable_ready#260, `cable_ready` changed its Content-Type to `text/vnd.cable-ready.json`. This commit updates the default one used to be compatible with `cable_ready`.
KonnorRogers
pushed a commit
to KonnorRogers/mrujs
that referenced
this pull request
May 25, 2023
…ready`: `text/vnd.cable-ready.json` (#209) * Update default Content-Type to reflect the one used by `cable_ready` Since stimulusreflex/cable_ready#260, `cable_ready` changed its Content-Type to `text/vnd.cable-ready.json`. This commit updates the default one used to be compatible with `cable_ready`. * Add some documentation about how `Accept` header can be modified
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of PR
Deprecation + Enhancement
Description
CableReady's
render operations:ActionController renderer doesn't indicate that it's coming/being used for CableReady operations. This pull request renames the renderer torender cable_ready:and adds a deprecation warning for theoperationsrenderer.Additionally it make the DX around it a little bit better by checking if the passed argument responds to
.dispatchbefore calling it. This helps when you already called.dispatchin the controller action or if you provide it a already converted JSON string.This pull request also changes the
cable_readyMIME type fromapplication/vnd.cable-ready.jsontotext/vnd.cable-ready.jsonso that the response from a controller action can be viewed in a browser.Finally, this pull request adds the
X-Cable-Ready-Versionheader to the response.Why should this be added
This is an effort to keep the naming consistent and scope all CableReady functions with its own name. Following up on #259, #252 and #250.
Checklist