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

1251Re: [json] Announcing web_send: a browser shell for JSON resources

Expand Messages
  • Kris Zyp
    May 7, 2009
      This looks really cool. Have you tried it with existing servers to see
      how compatible it is with current implementations of HTTP/JSON servers?
      This data interaction aspect of this looks similar to the functionality
      in Dojo's JsonRestStore, which can interact with CouchDB and Persevere.
      It'd be curious if your browser shell works with Persevere, as Persevere
      follows RFC 2616 pretty closely as well as some of the RESTful JSON
      conventions discussed here, such as JSON referencing:

      Tyler Close wrote:
      > The web_send library provides a concise and expressive API for
      > interacting with arbitrary JSON resources from the web browser. When
      > used from the Firebug console, it acts like a command line for your
      > web server; a great help during development of server-side code. The
      > same API is also convenient for creating an AJAX user interface to
      > JSON resources; so code born on the interactive command line migrates
      > smoothly into application code. This tutorial also links to a live web
      > page <http://waterken.sourceforge.net/bang/
      > <http://waterken.sourceforge.net/bang/>> where you can try out the
      > library against a simple server-side counter object.
      > For example, say you've got a brand new server-side object sitting at
      > a URL like: <https://example.com/myApp/obj123
      > <https://example.com/myApp/obj123>>. All you want to do is
      > invoke one of its methods, to see what happens. Using the web_send
      > library from the Firebug console, you could write:
      > factory = lib.web.getLocation(); // grab the window.location URL
      > drum = lib.Q.post(factory, 'makeDrum', []);
      > That code generates the following HTTP request:
      > POST /myApp/obj123?q=makeDrum HTTP/1.1
      > Host: example.com
      > Content-Type: text/plain; charset=UTF-8
      > Content-Length: 2
      > []
      > The arguments to Q.post() are:
      > 1. remote reference for the target object
      > 2. optional argument to add to the query string
      > 3. optional JSON value for the request body
      > The makeDrum() method didn't take any arguments. Here's one that does:
      > lib.Q.post(drum, 'bang', [ 1 ]);
      > Causing the HTTP request:
      > POST /myApp/obj456?q=bang HTTP/1.1
      > Host: example.com
      > Content-Type: text/plain; charset=UTF-8
      > Content-Length: 5
      > [ 1 ]
      > The target URL in the above request was taken from the HTTP response
      > to the previous request. For this to work, the web_send library
      > introduces some conventions for HTTP requests and responses. These
      > conventions are the least restrictive they can be, while still
      > supporting the client-side remote reference API. This document
      > explains these conventions and shows how to use legacy JSON resources
      > that don't follow the conventions.
      > ... (continue reading at <http://waterken.sourceforge.net/web_send/
      > <http://waterken.sourceforge.net/web_send/>>)
      > --
      > "Waterken News: Capability security on the Web"
      > http://waterken.sourceforge.net/recent.html
      > <http://waterken.sourceforge.net/recent.html>
    • Show all 3 messages in this topic