[Ur] Serving Non-XML Text?

Chris Double chris.double at double.co.nz
Fri Jan 25 22:58:13 EST 2013


On Sat, Jan 26, 2013 at 12:30 PM, Evan Danaher <ur at edanaher.net> wrote:
> Unfortunately, AFAICT, public functions returning "transaction page",
> and only such functions, are exposed as routes.  So I have to return
> JSON wrapped in XML, which is pretty ugly (and breaks compatibility with
> what I've got).  It wouldn't be too hard to add a thin proxy to strip
> this out, but I thought I'd check first if there's any support in Ur/Web
> for serving non-XML pages.

You can serve JSON with code like:

fun rate () =
  let
    val mimetype : mimeType = blessMime "text/plain"
    val json = "...json string here..."
  in
    returnBlob (textBlob json) mimetype
  end

You can build json from the result of queries with List.mapQuery to
get a list of results then form a JSON string from it.

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



More information about the Ur mailing list