Comments (14)
Hi there and welcome! I'm glad you're experiencing the joy of Hanami :)
I can look into this more on Monday but, in the meantime, this PR might be helpful: hanami/controller#396
Keep us updated, we may need to update the docs to reflect some nuanced behavior.
from hanami.
@cllns thanks for the link, it really helped me to find the issue.
So basically, this is the line triggering 406 status that I'm getting.
Looking into the PR you provided it seems that there was a accept
method that it should be used along with adding a new format, like this:
class CustomFromAccept < Hanami::Action
config.format custom: "application/custom"
accept :json, :custom
def handle(*, res)
But I get an undefined_method error when trying to use accept
(maybe it was removed?). So when it reaches the enforce_accept
method, it tries to match the basic accept headers text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
with the new custom mime type, but it doesn't match because custom doesn't match with any of the basic accept headers.
I think that if in the accept headers there is */*
it should be automatically accepted, right? You don't need to check since this means that any mime type is acceptable. This aceppted_mime_type? should be smarth enough to match */*
with anything. Or make the accept
work again?
from hanami.
Another finding from this PR - the accepted_formats config was removed
from hanami.
@dviana19 I was able to successfully use a format :turbo_stream
in an example Hanami 2.1 action, after setting that same config.
Check it out here and let me know if you still have any issues: https://github.com/cllns/example-app-format-turbo-stream
from hanami.
hey @cllns, thank you for replying. However, I cloned your repo and I still get the same error. I'm using docker, but I don't know if it's influencing the outcome here.
I get the 406 just by adding the following piece of code.
module Bookshelf
class App < Hanami::App
config.actions.formats.add :turbo_stream, "text/vnd.turbo-stream.html"
end
end
This is a request to /home action, which I removed the format :turbo_stream
from it and only left the piece of code above.
from hanami.
I've tried one fix: adding the turbo stream to the default types here. But I don't know if you want to go in that direction.
from hanami.
When you clone my repo and run rake test
, do both examples pass? They should. I have a test for the MIME type header. If there's some other issue then can you illustrate it with a failing test and share it? (preferably based on my example repo, either here or as a PR there)
from hanami.
Related Issues (20)
- Add db:migrate rake task
- Expand configurability of db provider HOT 1
- Register ROM commands and mappers from db/ directory
- Share DB connections between per-slice ROM containers using the same database URL
- Per-slice independent ROM setups
- Multiple slices sharing app-level ROM setup
- Automatically adjust database URL in test mode HOT 3
- Add `Slice.source_dir` method
- Add `Slice.app?` method
- Set ROM inflector be the same as the Hanami app inflector HOT 2
- Slice ROM setup with slice-specific database
- Expand default set of Sequel extensions HOT 5
- Configure db/ and structs/ directories not to be auto-registered
- Inside providers, add a `slice` alias for `target` HOT 13
- Incorrect name attribute handling in fields_for_collection helper when base name provided
- Label form helper errors when provided a symbol
- Offer to improve API Docs and Guides for FormFor helper HOT 2
- Load db provider if config dir exists
- Log SQL queries
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hanami.