Hacker Newsnew | past | comments | ask | show | jobs | submit | happyshadows's commentslogin

This is my approach as well. Works very well with an event-sourcing model.

It is much easier to capture user intent with POST /api/customer/1/change-address-due-to-move { "address_1": "...", "address_2": "...", ... }

than with: PUT /api/customer/1 { "address_1": "...", "address_2": "...", ... }

Also, GET /api/resource/action is nice place for a payload describing the expected inputs to the action. Link it all together with hypermedia and you really have something ;)

Believe others are coming around to this line of thought: ThoughtWorks included "REST without PUT" onto their technology radar earlier this year.


How about

    POST /api/customer/1/address {"address": "..."}


POST is used to create a resource. PUT is used to update an entire resource. PATCH is to partially update a resource.


Sure, just so long as you realize that is a convention and not a law.


It isn't just a convention, the reasons for doing this are laid out in the HTTP 1.1 spec and assumed by servers, proxies, browsers, clients and developers.

For example if I hand someone an API with a URI that accepts a PUT they know they can safely retry PUTs to that endpoint because the server state will always end up the same.


there is nothing in the specification of the PUT verb that indicates it is meant only for complete replacement of an existing resource. in fact, the RFC specifically has a section describing the semantics of creation using PUT. therefore, either your stance is trivially falsified, or you were replying to me out of context, which is intellectually dishonest.

https://tools.ietf.org/html/rfc7231#section-4.3.4


> The PUT method requests that the state of the target resource be created or replaced with the state defined by the representation enclosed in the request message payload.

So PUT either creates or replaces a resource.

Definition of replaced:

> 1. take the place of.

Source: https://www.google.com.au/search?q=define%3A+replaced

It is pretty clear to me that the spec says PUT completely replaces the state of a resource. So not just a convention but what the spec says.

BUT lets take it further. Lets say you do allow partial updates with a PUT. Can you guarantee that your resource's state will always be internally consistent?

Say you have two clients, both doing partial PUTs and do the following:

    Client 1: GET /foo
    Client 2: GET /foo
    Client 1: PUT /foo {'bar': 1}
    Client 2: PUT /foo {'baz': 2}
Is the foo resource is a consistent state? For some applications it could be but for many it won't be. And worse for some applications it may not be idempotent and a client's proxy is going to silently retry a PUT that isn't safe to do so.

So by allowing partial PUTs we're requiring the developer to consider all combinations a resource could be updated. They then need to communicate the valid combinations to any clients.

OR they can split the resource up finer grained resources, each one representing a valid PUT.


so since the post I replied to said that POST is for create, and PUT is for complete replacement, and you just indicated that PUT can be used in ways that the OP did not, and I objected to the OP's prescriptivism, you agree with me despite your stance of arguing with me about it.


Yes I seem to have misinterpreted your response. Apologies.


No worries! I happen to spend a lot of time designing REST APIs.


Why not PATCH /api/customer/1 {"address_1": "...", "history": "moved", ...} (i.e. send your intent as a parameter that may not necessarily get saved in this resource)


Because now your client needs to know what parts of the object need to be updated when a customer moves, and explain to the server exactly what those changes should be; and the server has to know how to validate that the client made a valid set of changes to the customer object.

If you instead have the client tell the server what kind of change you want to make, and provide the parameters to the operation, the server can do everything that needs to be done and the client doesn't need to care.


Same issue here. Now so off-track that I'll probably just change the content-type and call it a day.


I'm really sorry that this was your experience. I give a little bit of historical context elsewhere on this thread[1].

[1]: https://news.ycombinator.com/item?id=9280602


When Lord? When the hell do I get to see the goddamn sailboat?


Relax your eyes!

I've never been able to see one of these things on a screen until now. Now that I have, I really want too see an animated one.

The coolest thing so far is that you can click "redraw" and you'll cut to the next one and your eyes will already be focused for it.


Look, it's a schooner! ;)

There's pretty recent music video that's all autostereogram: https://www.youtube.com/watch?v=2AKtp3XHn38 The dots at the beginning are helpful.

I don't think MagicEye.js is fast enough to do a bunch of frames on the fly for some real-time animation, unfort. But if you already have the frames rendered you could stitch them together into a gif.


I did an animated 3d plasma for js1k some time ago. It's not fast but it's animated: http://js1k.com/2013-spring/demo/1412

h key toggles the height map.

It uses a simplified version of the MagicEye.js algorithm which generates horizontally repeating patterns for hard height changes in the source image. That's why I went with a plasma in the end.

Source is available here: https://github.com/philippstucki/sird-plasma/blob/master/3dp...


Really cool! I've wanted to see a dynamic animated MagicEye in action ever since I saw an Oculus Rift demo video with side by side left/right views and was able to get a 3D effect in the middle by focusing on it like a magic eye. It was hard to do because of the distance and looked pretty ugly because the separate L/R views were still visible. I tried to make my own but quickly gave up. If snappier animation is possible, there's definitely some fun to be had in game form. Recreations of the old vector based arcade games would be really fun. I wounder if there would be any effect, bad or good, on your eyes staring at one for too long.


Sick!


Here's how I do it: you'll notice that there's a repeating pattern, cross your eyes until you get two of the repititions to be on top of each other. Once you've done this you should find that the shapes pop out.


This is how I do it. The problem is that this inverts the depth map, because your right eye sees the left eye image and vice-versa.

To properly view them, you need to go wall-eyed, by focusing on something behind the screen. This is something that I have not been able to do yet.


The other problem with the cross-eyed technique is that it can be hard to maintain a sharp focus on the 3D shapes. And it will really hurt after a while.

It's a good technique if the repeating strips are really wide. On my screen at least, the strips here are pretty narrow, so it should be relatively easy to converge your eyes correctly.

Having said that, I don't know if this script is resolution independent, so it's possible that on some monitors the strips are a lot wider than they should be and that could be giving people more trouble.


Seems like a throwback to the days of the web portal (ala Yahoo.)


yes, like a mixture of:

* original The Microsoft Network (1994-1995) the MSN client that shipped with Win95 (instead of a web browser) that was meant as an alternative to the WWW; or similar limited portal services like America Online, CompuServe that are now obsolete

* portal websites with widgets like Yahoo, AltaVista, MSN (1996+)

* HTML5 web app store (btw. the Mozilla smartphone shown in the video already has an official Mozilla web app store)


Mutations is a great gem. I've used in my latest project and it has been an exceptionally useful tool for managing complexity.


I wish Google would change their meta-tag from "origin" to "always". It's getting harder and harder to see which keywords bring traffic to your site these days.


Analytics calculates the time on page by the time difference _between_ page hits. One hit: 0 seconds on site. Because of this, it isn't an accurate metric to measure engagement for a single blog post.


I assumed they have some fancy javascript thing to take care of that? what would you suggest to use to estimate actually readership?


I would stick with GA and just trigger an event via javascript once the body of text is scrolled through.

If I didn't know how to do that, I would probably use a scrollmap tool like CrazyEgg.


One of the tangental points you raised was wrong so you are wrong!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: