Comments (8)
@Kyrremann how did you solve it at the end?
from roda.
I've solved it by adding the content-type
to all my outgoing calls.
See here: https://github.com/Kyrremann/TagStoryApi/blob/master/routes/v1.rb
from roda.
Ahh, Thanks! I did the same! 👍
from roda.
Maybe the json plugin could allow the Content-Type to be configured, instead of having "application/json" hardcoded. I'm for example using this plugin to do serialization of records (the plugin allows you to easily make your own serialization which can be anything), and maybe (god forbid) I would need to return XML, in which case it would be useful to be able to set "application/xml". The plugin is named "json", but since it already supports custom serializers, it would be cool if it also supported custom Content-Type (preferrably dynamic, so that it can for example be different depending on the "Accept" request header).
from roda.
I'm fine with allowing customization of the content type, can someone submit a pull request for it?
from roda.
I'm working on a small Pull Request, but I'm not sure what you meant by dynamic content-type.
from roda.
If you're serializing records, an often use case is that you allow different formats to be returned (JSON, XML, CSV etc), so I thought it would be nice that this plugin is also able to set the Content-Type header depending on the request (if a user requests this resource in JSON format, set "application/json", if other user requests this resource in XML, set "application/xml", and so on).
However, I think a better idea is that the plugin sets the Content-Type only if it's not already set (just by using ||= instead of =), so that users are rather able to set the Content-Type manually, without the plugin overriding it. That's solves it perfectly, I think.
But I see now that this is a separate change, so you just continue with your PR, I might make a PR for this afterwards :)
from roda.
I've made a Pull Request now, so please take a look #58.
I went for the more elaborated way where you need to set the content-type as an option for the plugin, instead of just setting the content-type if it's not already set (see the last comment).
I think this is best as it makes it more explicit.
from roda.
Related Issues (20)
- Envrionments plugin: provide instance methods too? HOT 1
- How can i load coffeescript in roda HOT 2
- How to use common_logger plugin to log information in routes implementation or in specs or other place in the application? HOT 6
- [feature request] Make the view method (from the render plugin) accept a block like the render method does HOT 1
- route_csrf incompatible with rack-protection authenticity token checks HOT 5
- Unfork HOT 3
- env['rack.errors'] parsed as a link in common_logger plugin documentation HOT 2
- String matcher in hash_routes combined with unescape_path does not match non-ascii strings HOT 1
- [Documentation / Question] Request for a FAQ for experienced sinatra users HOT 1
- Raises "Unsupported block result" when using Unreloader and json plugin HOT 2
- On app startup. Getting message > Rack::Handler is deprecated and replaced by Rackup::Handler HOT 2
- Not compatible with Haml >= 6 HOT 2
- URI Unicode handling HOT 6
- Duplicating Content-Type header when header key comes in lowercase HOT 3
- json plugin does not support FalseClass and String anymore HOT 1
- Can gRPC services and clients be integrated?
- Unicode escapes not decoded in path HOT 3
- Sanitize params when using plugin `error_mail` HOT 2
- Missing rackup on clean install HOT 4
- Bundler, Zeitwerk & Roda Plugins HOT 5
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 roda.