Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Combining a web application and a REST application under a single URI?

by thraxil (Prior)
on Jul 20, 2006 at 23:57 UTC ( #562741=note: print w/ replies, xml ) Need Help??


in reply to Combining a web application and a REST application under a single URI?

Don't add your own header field, use the Accept header. That's what it's for.


Comment on Re: Combining a web application and a REST application under a single URI?
Re^2: Combining a web application and a REST application under a single URI?
by Aristotle (Chancellor) on Jul 21, 2006 at 00:31 UTC

    Yep, exactly.

    For the human-friendly pages with forms on them, and the URIs that handle them, you probably cant get away with talking to the REST API directly, though. To be usable, the human interface often needs to handle updating multiple resources at once in some fashion, or may have functional aspects that cant be associated with any particular resource in the system. Trying to build an interface that rigidly follows the resource structure of an app just makes for a mediocre user experience, at best.

    So Id have the bookmarkable friendly URIs be capable of returning both human-friendly and machine-readable representations via Accept, and maybe also have them respond to programmatic access (by PUTting/POSTting with a request body with XML or JSON or something like that), but Id have a separate URI space to handle the browser-based editing UI.

    Makeshifts last the longest.

        So Id have the bookmarkable friendly URIs be capable of returning both human-friendly and machine-readable representations via Accept, and maybe also have them respond to programmatic access (by PUTing/POSTing with a request body with XML or JSON or something like that), but Id have a separate URI space to handle the browser-based editing UI.

      My plan is to provide RESTful access via the Accept header types of text/xml and application/xml, and web access (menus, CSS) for application/xhtml+xml and text/html. The problem that I'm trying to solve now is that Firefox uses the following accept header: Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5. I guess this means my application will always have to provide HTML of some sort, unless the script asks only for XML, in which case I provide XML, in a "Just the facts, Ma'am" [1] format.

      Alex / talexb / Toronto

      "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      1. Obligatory link to Snopes for the pedants in the crowd. The quote is actually "All we want are the facts, ma'am."

Re^2: Combining a web application and a REST application under a single URI?
by talexb (Canon) on Jul 21, 2006 at 14:13 UTC
      Don't add your own header field, use the Accept header. That's what it's for.

    Thanks, and for those following along at home, that's section 14.1 of the HTTP 1.1 specification. Select 'text/xml' and we're off to the races (and I may add application/xml as well).

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      Reminder: Since you are delivering different HTTP responses according to a UA supplied header field, you must add the appropriate Vary header to your HTTP response.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://562741]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2014-04-20 02:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls