On Sun, Nov 9, 2008 at 5:40 AM, Tim Perrett <[EMAIL PROTECTED]> wrote:

>
>
> > Is that lowlevel Lift code or supposed to be how you use the API?
> >
> > If it's the latter I think there's some improvements that can be done ;)
>
> Thats lift framework code :-)
>
> Like i said, i've not used it before, but I believe you'd then do
> something like this in Boot.scala:
>
> LiftRules.determineContentType = {
>  case (_, Full(accept)) if LiftRules.useXhtmlMimeType &&
> accept.toLowerCase.contains("application/xhtml+xml") => "application/
> xhtml+xml"
>   case (Full(RequestState(_,"json",_)), Full(accept)) => "text/x-json"
>  case _ => "text/html"
> }
>
> Obviously as your getting a RequestState passed to the function, you
> can do a whole bunch of matching. NB: I've not tested this code, its
> just from the tope of my head but I think it should work :-)


Tim,

The above code is only related to the XHTML render pipeline... stuff that
goes through Lift's view mechanism.  It would be a Bad Thing (tm) to set
JSON as the return type in this case as the result is going to be XHTML.
The reason we've got this particular bit of code is to deal with IE 6/7 (no
XHTML support and barfs on "application/xhtml+xml" headers but modern
browsers (FF, Safari, etc.) require the content type to properly render the
page (not apply some alternative of HTML tag soup to the page.)

More broadly, the content-type must match what is actually being rendered.

In the case of APIs, you will have alternative dispatches to functions that
are going to render the result *and* set the content-type headers
appropriately.

I've been noodling on some sort of meta-representation of stuff that could
be auto-converted into XML or JSON, but the noodling hasn't gone too far.

Thanks,

David


>
>
> Cheers
>
> Tim
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
Follow me: http://twitter.com/dpp
Git some: http://github.com/dpp

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to