Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable passing response options #307

Open
yayitswei opened this issue Feb 9, 2019 · 1 comment
Open

Disable passing response options #307

yayitswei opened this issue Feb 9, 2019 · 1 comment

Comments

@yayitswei
Copy link

yayitswei commented Feb 9, 2019

Hi, thanks so much for making liberator.

It seems some behavior has changed since I last updated liberator and broke some of my endpoints. A resource that previously returned a JSON response with a key named status now incorrectly puts that value into the status code. As this is a large system with other dependencies, it's infeasible to change the response keys, for example, renaming the key from status to page-status. Can you advise on a way to keep the status key in the response in this new version of liberator, perhaps disabling the new behavior?

I believe it could be this update in 0.13 that broke the functionality I've been relying on:

New in 0.13

- Optionally a value can be specified for ring-response together with a ring map. This value is coerced to a response like liberator does by default while the ring map makes it possible to override whatever part of the response.
@yayitswei
Copy link
Author

yayitswei commented Feb 9, 2019

Here's an example:

(ns liberatortest.core
  (:use [liberator.core :only [defresource]]
        [ring.mock.request :only [request header]]
        [liberator.dev]))

(defresource hello-world
  :available-media-types ["application/json"]
  :malformed? [true {:status :testing}]
  :handle-ok "ok")

liberator 0.12.2 would put {:status :testing} in response body. liberator 0.15.2 overrides the :status field, resulting in:

{:status :testing, :headers {"Content-Type" "text/plain;charset=UTF-8"}, :body "Bad request."}

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

No branches or pull requests

1 participant