News for hackers. Stuff that matters.
Re:Internet of Desks: How I Connected My Standing Desk to th... by ApeTheRick on Monday April 22, 2024 @10:31AM (#40114752)
GET requests should be idempotent - browsers will call them without explicitly asking to, if bookmarked etc. Reminds me of the old story here

https://twitter.com/rombulow/status/990684453734203392

Maybe consider changing setting the height to a POST request

Re:Internet of Desks: How I Connected My Standing Desk to th... by kn100 on Monday April 22, 2024 @10:36AM (#40114795)
Hehe, you're not the first person to have suggested this, and I was wondering how quickly the HN crowd would find and point it out. You're definitely right, but to explain why it is the way it is right now:

* I just didn't want to mess about with postman or curl or whatever in order to test, much easier to just issue a get request by visiting a url in the browser

* I'm going to be ripping the HTTP support out shortly and replacing it with MQTT support so it can more cleanly integrate with my HomeAssistant setup. The HTTP stuff was mostly just the fastest way I could get something approximating what I was looking for.

I definitely agree though, this being a `GET` request is offensive :P

Re:Internet of Desks: How I Connected My Standing Desk to th... by exchemist on Monday April 22, 2024 @12:35PM (#40115988)
When I'm making a throwaway interface like this, I write the GET handler to return a super-minimal page with an unstyled form having method=POST and the couple of inputs required. The POST handler actions the request and redirects to itself to GET the form again - browsers are so forgiving of incomplete/incorrect markup and the base browser style-sheet screams "this is a prototype, don't judge it!" to anybody you show it to.

To be clear I'm just talking about the web interface, not implying the whole project is throwaway - on the contrary it looks like a lot of work (and a lot of fun :) ) kudos!

Re:Internet of Desks: How I Connected My Standing Desk to th... by kn100 on Monday April 22, 2024 @02:53PM (#40117533)
that's a great idea and one I'm stealing for the future! thanks.
Re:Internet of Desks: How I Connected My Standing Desk to th... by ApeTheRick on Monday April 22, 2024 @10:48AM (#40114912)
Makes sense - I had visions of you sat at your desk, opening a new tab and it suddenly turning back to the standing position!

Thanks for the post though, a fun read!

Re:Internet of Desks: How I Connected My Standing Desk to th... by Filligree on Monday April 22, 2024 @10:32AM (#40114767)
> This, kids, is why GET requests should be idempotent.

I'm not sure I understand. What is this referring to?

Re:Internet of Desks: How I Connected My Standing Desk to th... by bombcar on Monday April 22, 2024 @10:55AM (#40115008)
https://threadreaderapp.com/thread/990684453734203392.html

Had a GET request that would open or close the garage door.

Safari learned he liked that page, and would hit it every time he opened a new tab on any device.

Re:Internet of Desks: How I Connected My Standing Desk to th... by Filligree on Monday April 22, 2024 @11:04AM (#40115105)
Ah, I see...

POST requests should be idempotent, ideally. PUT requests certainly must be; it's their defining characteristic. GET requests, though, just shouldn't have side-effects at all.

(A /toggle URL isn't idempotent. If it were /open and /close it would be, but still shouldn't be GET.)

Re:Internet of Desks: How I Connected My Standing Desk to th... by bombcar on Monday April 22, 2024 @11:50AM (#40115510)
Yeah I think people are saying "GET shouldn't change state" and using idempotent incorrectly (which is more "hitting this multiple times shouldn't change things more than once").
Re:Internet of Desks: How I Connected My Standing Desk to th... by ApeTheRick on Monday April 22, 2024 @10:33AM (#40114776)
I think the twitter link is messed up, I have to scroll up to see the whole thread.

Edit: Fixed the link now.

Re:Internet of Desks: How I Connected My Standing Desk to th... by tjoff on Monday April 22, 2024 @12:10PM (#40115702)
Twitter threads are always messed up if you don't have an account. You can't follow the thread at all.