Git Product home page Git Product logo

Comments (8)

seigur avatar seigur commented on September 23, 2024

@Kyrremann how did you solve it at the end?

from roda.

Kyrremann avatar Kyrremann commented on September 23, 2024

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.

seigur avatar seigur commented on September 23, 2024

Ahh, Thanks! I did the same! 👍

from roda.

janko avatar janko commented on September 23, 2024

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.

jeremyevans avatar jeremyevans commented on September 23, 2024

I'm fine with allowing customization of the content type, can someone submit a pull request for it?

from roda.

Kyrremann avatar Kyrremann commented on September 23, 2024

I'm working on a small Pull Request, but I'm not sure what you meant by dynamic content-type.

from roda.

janko avatar janko commented on September 23, 2024

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.

Kyrremann avatar Kyrremann commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.