A RESTful framework for rapid development in MarkLogic Server ( XQuery, XML )
XQuery
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
lib
models
public
representations
resources
templates
.gitignore
404.xqy
LICENSE
README
default.xqy
error-handler.xqy
getfile.xqy
invoke.xqy
rewrite.xqy

README

What is this?
''''''''''''
A RESTful framework for rapid development in marklogic server

Should I use it?
'''''''''''''''
This is not usable - refer to RDBC for a proof of concept that actually works
currently cleaning up the code and adding more functionality

Next steps
''''''''''
  - Make it work with defaults, doing something just to show
  - Then generalize everything and program the generators
    - Most likely in ruby
  - Code the tests
    - Most likely in cucumber, because miguel said its cool
  - Then implement the caches
    - To prevent the heavy calculations
  - Add /_sessions folder
  - Add method to sanitize input, or make it automatic with the generated
    xml. Maybe sanitized inputs
  - No layoutsÉ We need layouts or its just crazy
  - Make a twitter like chat app (just for javscript)
  - Improve code - too early stages and ugly
    

I'm trying to get ahead of you, but what's this cache thingy?
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
It's a mapping, that going to be stored in something like a persistent 
memcached inside marklogic (using range indexes). This is how it looks like
for the sample routes that come with the instalation.

<d:cache xmlns:d="http://ns.dscape.org/2010/dylan/core">
  <d:kvp key="get /user/:id" value="/resources/user.xqy?_action=get"/>
  <d:kvp key="post /user/:id" value="/resources/user.xqy?_action=post"/>
  <d:kvp key="put /user/:id" value="/resources/user.xqy?_action=put"/>
  <d:kvp key="delete /user/:id" value="/resources/user.xqy?_action=delete"/>
  <d:kvp key="get /album/:id" value="/resources/album.xqy?_action=get"/>
  <d:kvp key="post /album/:id" value="/resources/album.xqy?_action=post"/>
  <d:kvp key="put /album/:id" value="/resources/album.xqy?_action=put"/>
  <d:kvp key="delete /album/:id" value="/resources/album.xqy?_action=delete"/>
  <d:kvp key="get /album/:id/songs" value="/resources/album.xqy?_action=songs"/>
  <d:kvp key="get /feed" 
    value="/lib/dylan/redirect.xqy?url=http%3a//feedburner.com/sample_feed"/>
  <d:kvp key="get /logout" value="/resources/sessions.xqy?_action=delete"/>
  <d:kvp key="get /activate/:key" value="/resources/user.xqy?_action=activate"/>
  <d:kvp key="get /" value="/resources/album.xqy?_action=list"/>
  <d:kvp key="get /:resource/:action/:id" value="/lib/dylan/invoke.xqy"/>
</d:cache>

Ideas
'''''
  1) Supporting compression (gzip) would be nice for put, get and post
     but requires a slightly more complicated client (and server)
  2) Application level security allows protecting some calls while
     leaving others unprotected
  3) User agent to drive browsers to html and curl to xml
  4) A memcached implementation
     /_caches/song.xml
     /_caches/_setup.xml    -> stores things that are created on startup
     /_caches/_routes.xml   -> stores the routes
     /_caches/_app.xml      -> page cache for sweeping
     /_caches/_consistenthash.xml
     create your own
  5) Use directories in database to store those files
  6) Introduce notion of tasks (spawns)
  7) We need a restful way to address the admin api...
     Maybe narthex, maybe the api itself as its already deployed in every
        marklogic install (sounds like a good default)
  
Sample Invocations
''''''''''''''''''

  1) Create file one.xml (you need an xml file named one.xml in the working directory)

     curl \
       --request POST \
       --data "@one.xml" \
       --anyauth \
       http://user:pwd@localhost:8010/doc/one.xml

 2) Update file book.xml (you need an xml file named two.xml in the working directory)

    curl \
      --request PUT \
      --data "@two.xml" \
      --anyauth \
      http://user:pwd@localhost:8010/doc/one.xml

 3) Get file book.xml in json

    curl \
      --header "Accept: application/json" \
      --anyauth \
      http://user:pwd@localhost:8010/doc/one.xml 

 4) Get file book.xml
 
    curl \
      --anyauth \
      http://user:pwd@localhost:8010/doc/one.xml 

 5) Delete file one.xml

  curl \
     --request DELETE \
     --anyauth \
     http://user:pwd@localhost:8010/doc/one.xml

  6) An invalid route
  
     curl \
       --header "Accept: application/json" \
       --anyauth \
       http://user:pwd@localhost:8010
       
document inserts
''''''''''''''''
xdmp:document-insert("/album/bon+jovi-a+dummy+album.xml",
  document { <album>
    <title> A Dummy Album </title>
    <artist> Jon Bon Jovi </artist>
    <song> One </song>
    <song> Two </song>
  </album> }
);
xdmp:document-insert("/album/brian+adams-a+summer+album.xml",
  document { <album>
    <title> A Summer Album </title>
    <artist> Brian Adams</artist>
    <song> Yet </song>
    <song> Another </song>
  </album> }
)