Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

@Put and @Delete annotations return type #275

Description

@louishuh

Hi.

I'm happy to know this project.

It's really useful and exciting.

I have a question.

Why @put and @delete annotations are not supporting return type?

HTTP Protocol has rule about these body?

Actually, My api service responses with body.

So I really want to use these annotations with return type.

Sorry for my English. I'm learning it;;

Activity

  1. pyricau commented on Aug 2, 2012

    @pyricau
    Contributor

    I think you're right. @a-thomas, what do you think ?

  2. pyricau commented on Aug 2, 2012

    @pyricau
    Contributor
  3. louishuh commented on Aug 16, 2012

    @louishuh
    Author

    I hope this issue be assigned.

    Thank you, Pyricau.

  4. a-thomas commented on Sep 4, 2012

    @a-thomas
    Contributor

    Hi, sorry for the late reply.

    I don't know any specific HTTP rules about PUT and DELETE response bodies. I think that you can return what you want. But, PUT and DELETE generally don't need to return anything. Indeed, an appropriate HTTP status code (200, 201...) is sufficient.

    So, the question is : What do you want to return ?

    Anyway, we initially implement the RestTemplate like the official Spring RestTemplate way. Let's see the 2.5.6 section of the documentation about PUT method. That explains what PUT and DELETE methods only return void.

  5. louishuh commented on Sep 6, 2012

    @louishuh
    Author

    Yeah... Spring's Resttemplate returns void for PUT&DELETE.

    So, I use 'resttemplate.exchange(...)' method usually.

    look at this url: https://jira.springsource.org/browse/SPR-7583

    umm... I use for somthing additional information. It's difficult to explain.

    Thank you, a-thomas

  6. pyricau commented on Sep 6, 2012

    @pyricau
    Contributor

    @a-thomas I think we use exchange anyway, right ? So we could actually implement this, am I correct ?

  7. royclarkson commented on Sep 6, 2012

    @royclarkson
    Contributor

    As @a-thomas said, PUT and DELETE don't normally require a response body, which is why we don't return anything in the put() and delete() convenience methods within RestTemplate. If a response body is desired, then using the exchange() method as @pyricau suggested, should give you what you need.

  8. a-thomas commented on Sep 6, 2012

    @a-thomas
    Contributor

    Yes indeed, we use the exchange() method for flexibility reasons. In fact, the first one was the modification of the HTTP header fields.

    So, there is no problem for this implementation. Just doing like @POSTand @GET methods that they're already implemented.

    I just was interested in what @louishuh returned in their @PUT and @DELETE methods :)

    Anyway, I'll do it ASAP. Thanks @royclarkson for your reply ;)

  9. mathieuboniface commented on Nov 24, 2012

    @mathieuboniface
    Contributor

    @a-thomas any update about this ?

  10. rockytriton commented on May 23, 2013

    @rockytriton
    Contributor

    Where I work, all of our rest APIs have a request and response object attached, even PUT and DELETE. I agree that it should be supported.

  11. JoanZapata commented on May 24, 2013

    @JoanZapata
    Contributor

    @a-thomas I have a common use case (the 9-months late use case, ah ah)

    It's common to identify all business objects with a unique ID.
    When you create a new object, you call POST with all the required attributes except this ID, because it's filled by the server.

    How do you get this ID if you don't return anything ? You'd have to GET the whole list to retrieve the newly created one. Almost all POST methods in my project return the object they just created, because it can contain other attributes or fix the submitted ones :

    ➡️ { name: "Hello" }
    ⬅️ { id: 1, creation_date: 1369376193, owner: "XXX", name: "HELLO" }

  12. DayS commented on May 24, 2013

    @DayS
    Contributor

    Seems legit :) We definitely have to implement this.

  13. lalith-b commented on Nov 20, 2013

    @lalith-b
    Contributor

    The return type for put and delete annotations is handled and was merged in pull #748

  14. DayS commented on Nov 20, 2013

    @DayS
    Contributor

    Nice catch. The wiki was already updated for this part. I changed milestone to 3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions