Git Product home page Git Product logo

Comments (9)

malcolmsparks avatar malcolmsparks commented on June 23, 2024

Yes, after consideration I think yada should support returning a body in PUT/POST as per the lines of the spec. Let's keep this issue open.

from yada.

tangrammer avatar tangrammer commented on June 23, 2024

Hi guys!
Do we have some shortcut for having body in PUT until proper impl and release?
I'm trying this with no lucky

(defrecord MyRecordType [d])

(extend-protocol PutResult
  MyRecordType
  (interpret-put-result [o ctx]
    (assoc-in ctx [:response :body] (:d o))))

from yada.

malcolmsparks avatar malcolmsparks commented on June 23, 2024

PUT bodies should work - see the phonebook example. Or do you mean
response bodies?

On 8 March 2016 at 10:35, tangrammer [email protected] wrote:

Hi guys!
Do we have some shortcut for having body in PUT until proper impl and
release?
I'm trying this with no lucky


Reply to this email directly or view it on GitHub
#26 (comment).

from yada.

tangrammer avatar tangrammer commented on June 23, 2024

sorry, I meant response bodies :)

from yada.

tangrammer avatar tangrammer commented on June 23, 2024

Thanks Malcolm!
could i ask you to do a release including this commit?
BTW: I tried to find tag xxxx-32 to work on top of it but i couldn't find it

from yada.

malcolmsparks avatar malcolmsparks commented on June 23, 2024

Yes... but my tests fail :(

But give me a couple of hours...
On 8 Mar 2016 13:57, "tangrammer" [email protected] wrote:

Thanks Malcolm!
could i ask you to do a release including this commit?
BTW: I tried to find tag xxxx-32 to work on top of it but i couldn't find
it


Reply to this email directly or view it on GitHub
#26 (comment).

from yada.

tangrammer avatar tangrammer commented on June 23, 2024

👍 👍

from yada.

malcolmsparks avatar malcolmsparks commented on June 23, 2024

Hi,

You can do this by returning a modified response, which yada's method proxy
interprets that you want to control what is returned.

(testing "return response"
(let [h (yada (resource {:methods {:put {:response (fn [ctx](assoc
%28:response ctx%29 :body))}}}))
response (h (request :put "/"))](is %28= "BODY" %28b/to-string %28:body @response))))))

I've had to back out the last commit because it broke some test, but I've
added the above test which passes.

Regards,

Malcolm

JUXT LTD.
Software Consulting, Delivery, Training

On 8 March 2016 at 14:59, tangrammer [email protected] wrote:

[image: 👍] [image: 👍]


Reply to this email directly or view it on GitHub
#26 (comment).

from yada.

stanislas avatar stanislas commented on June 23, 2024

Thanks for the solution :)

I had to change the status to 200 in order to have aleph (or the yada handler?) actually serving the body. (with status 204, the body is not send, although the header contains a correct content length). To reflect that, I prepared a PR with the corresponding change in the test.

Pull Request: #72

from yada.

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.