nicolasff / webdis

A Redis HTTP interface with JSON output
https://webd.is
BSD 2-Clause "Simplified" License
2.82k stars 305 forks source link

is there any possibility you could make a example where you post data? #70

Closed triptec closed 11 years ago

nicolasff commented 11 years ago

Hello,

By "posting data", do you mean sending a command using HTTP POST? If so, the format is documented in the README:

Is there a particular issue I could help you with?

Regards,

Nicolas

triptec commented 11 years ago

Well I found myself doing this $.get "http://xxx.xxx.xxx.xxx:7379/SET/some_user/"+encodeURIComponent(JSON.stringify({firstname: "some name", lastname:"some lastname"}))

I'm just thinking it's not the best way =) ANDREAS FRANZEN | DEVELOPER | M +46 60 52 52 19 | ANDREAS.FRANZEN@OSYNLIG.SE Osynlig AB | Torggatan 8, 3rd floor | S-85230 Sundsvall | +46 60 525 220 | osynlig.se

On Mar 25, 2013, at 3:04 PM, Nicolas Favre-Felix notifications@github.com wrote:

Hello,

By "posting data", do you mean sending a command using HTTP POST? If so, the format is documented in the README:

GET /COMMAND/arg0/.../argN.ext POST / with COMMAND/arg0/.../argN in the HTTP body. Is there a particular issue I could help you with?

Regards,

Nicolas

— Reply to this email directly or view it on GitHub.

nicolasff commented 11 years ago

Right, so you can send a POST request to / with the request body being SET/someuser/...json-here...

triptec commented 11 years ago

Okay, could we add something like this to the read me?

$.post("http://xxx:7379", "SET/someuser/" + JSON.stringify({firstname: "some name", lastname:"some lastname"}), function(data){console.log(data)});

Object {SET: Array[2]} SET: Array[2] 0: true 1: "OK" length: 2

$.post("http://xxx:7379", "GET/someuser", function(data){console.log(data)});

Object {GET: "{"firstname":"some name","lastname":"some lastname"}"}

I think it might help people not to comfortable with curl and command line to put in the time to use this awesome thing! =) I use it for rt.spotalike.com and it works really good, even if it looks ugly with the query and all JSON.stringify

Thank for the help! ANDREAS FRANZEN | DEVELOPER | M +46 60 52 52 19 | ANDREAS.FRANZEN@OSYNLIG.SE Osynlig AB | Torggatan 8, 3rd floor | S-85230 Sundsvall | +46 60 525 220 | osynlig.se

On Mar 25, 2013, at 3:31 PM, Nicolas Favre-Felix notifications@github.com wrote:

Right, so you can send a POST request to / with the request body being SET/someuser/...json-here...

— Reply to this email directly or view it on GitHub.

nicolasff commented 11 years ago

@triptec I am not sure that Javascript documentation has its place in the webdis docs, anymore than Python or Ruby examples. Curl is the simplest way of describing this HTTP-based API, which is documented for GET, POST, and PUT requests. The docs are about this standard protocol, not about a particular way of using HTTP requests in language X or Y. On that note, I have added the docs for PUT alongside GET and POST in the section linked above.

Regards,

Nicolas

triptec commented 11 years ago

i personally would have liked a js, ruby and php example in the bottom. The faster someone can try an idea the more likely he is to try I'd say. And also I think js is really good as anyone could try it in their browser console. Not everyone on linux and mac use their terminals that much. Anyways, if you'd like me to write a example or even a few please let me know, otherwise thanks for a neat solution.

ANDREAS FRANZEN | DEVELOPER | M +46 60 52 52 19 | ANDREAS.FRANZEN@OSYNLIG.SE Osynlig AB | Torggatan 8, 3rd floor | S-85230 Sundsvall | +46 60 525 220 | osynlig.se

On Mar 25, 2013, at 6:37 PM, Nicolas Favre-Felix notifications@github.com wrote:

@triptec I am not sure that Javascript documentation has its place in the webdis docs, anymore than Python or Ruby examples. Curl is the simplest way of describing this HTTP-based API, which is documented for GET, POST, and PUT requests. The docs are about this standard protocol, not about a particular way of using HTTP requests in language X or Y. On that note, I have added the docs for PUT alongside GET and POST in the section linked above.

Regards,

Nicolas

— Reply to this email directly or view it on GitHub.