[Ur] Handling POST requests that aren't from forms

Chris Double chris.double at double.co.nz
Wed Dec 15 09:54:15 EST 2010


On Thu, Dec 16, 2010 at 2:57 AM, Adam Chlipala <adamc at impredicative.com> wrote:
> No, this should be a form with no fields, and the beginning [notifyMessage]
> should be changed like:
>    fun notifyMessage body () =
> so it expects an extra empty record of form fields (which doesn't affect the
> URL format).

This is what the post request looks like that I'm receving:

----------8<-------------
Content-Type: application/json
Content-Length: 19

{"message":"hello"}
----------8<-------------

The Ur/Web code I have is like:

----------8<-------------
fun notifyMessage () =
   msg <- ...how do I get the value of the POST request body here...
              ...such that msg is the string "{\"message\":\"hello\"}"
   dml (INSERT INTO debug (Message) VALUES ({[msg]}));
  return <xml>0</xml>

fun dummyForm () =
  return <xml>
  <body>
    <form >
      <submit action={notifyMessage}/>
    </form>
  </body>
  </xml>
----------8<-------------

Is it possible to get access to the original POST body in notifyMessage?

Chris.
-- 
http://www.bluishcoder.co.nz



More information about the Ur mailing list