Loading ...
Sorry, an error occurred while loading the content.

Re: [rest-discuss] Re: How to design "A follows B"

Expand Messages
  • Nathan
    just a side note, you could always use activity streams too..
    Message 1 of 6 , Mar 21, 2011
    View Source
    • 0 Attachment
      just a side note, you could always use activity streams too..

      Viswanath Durbha wrote:
      > Thanks for the thoughtful and detailed responses.
      >
      > I actually like the new resource that parameterizes the friendship. That
      > way, as you said, I can just DELETE the resource and it will be idempotent
      > as well.
      >
      > By the way, the twitter REST API you're trying to build will have to use the
      > official "REST" API of twitter at the backend, right?It feels a little odd
      > to create an api on top of another api for the same purpose as I'm also
      > trying to do something like that.
      >
      > On Mon, Mar 21, 2011 at 11:52 PM, Duncan <rest-discuss@...> wrote:
      >
      >>
      >>
      >>
      >> So, what if you want to un-friend 'B' in the "POST /A/friends /B" approach?
      >>
      >>
      >> You first need to understand the POST body as a declaration of your
      >> intention - here's a slight adjustment to clarify that:
      >>
      >>
      >> GET /A/friends
      >>
      >> [ /M, /F, .. ]
      >>
      >> POST /A/friends
      >>
      >> friend /B
      >>
      >>
      >> GET /A/friends
      >>
      >> [ /B, /M, /F, .. ]
      >>
      >> Note the change to "friend /B".
      >>
      >> Note also that this is declarative and idempotent, where the imperative
      >> "add /B" approach could potentially cause repeated /Bs if the POST were
      >> repeated.
      >>
      >> You can now say:
      >>
      >> POST /A/friends
      >>
      >> unfriend /B
      >>
      >> to declare that you intend B to be missing now from your friends list.
      >>
      >> These examples are sketches, and the Media Type for the POST body should of
      >> course be widely-recognised, which means the form type, or JSON, or whatever
      >> your collaborators are happy with. I don't know of any standards that can be
      >> re-used to do 'friend' and 'unfriend' - you may have to drop down to less
      >> semantic data editing formats.
      >>
      >> Again, just "PUT /A/friends [ /M, /F, .. ]" would work, but that's a
      >> pattern that really only applies to smaller lists that you have control
      >> over, rather than large lists or lists that are changing a lot.
      >>
      >> Or do the alternative I suggested, of a new resource parameterising your
      >> friendship, which can be DELETEd.
      >>
      >> Cheers!
      >>
      >> Duncan
      >>
      >>
      >>
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.