

Clojure Web Development with Ring - swannodette
http://mmcgrana.github.com/2010/03/clojure-web-development-ring.html

======
swannodette
I mentioned this on another submission but Christophe Grand's Moustache
routing library, <http://github.com/cgrand/moustache>, is great in conjunction
with Ring. It makes very idiomatic use of destructuring to define routes, for
example you can do stuff like the following:

    
    
      (def admin-post
         (app [""]        "admin post index"    ; /admin/post/ or /admin/post
              ["new"]     {:get new-post        ; GET  /admin/post/new
                           :post save-post}     ; POST /admin/post/new
              ["edit" id] {:get edit-post}))    ; GET  /admin/post/edit/:id
    
      (def admin
         (app [""]         "admin index"        ; /admin/ or /admin
              ["post" &]   admin-post           
              ["posts"]    {:get all-posts}     ; /admin/posts
              ["settings"] {:get settings}))    ; /admin/settings
    
      (def main
         (app [""]          "index page"        ; /
              ["post" slug] {:get get-post}     ; /post/:slug
              ["admin" &]   admin))

------
icey
(loaded question alert)

What differentiates Ring from Compojure? What is the appropriate use case for
Ring vs Compojure?

~~~
mmcgrana
Ring is a lower-level library than Compojure. It provides a variety of common
web-related utilities that will be needed by many Clojure web developers,
regardless of what higher-level libraries they choose to use. The purpose of
Ring is to prevent those utilities from being rewritten all over the place
while also allowing custom utilities to be shared among Clojure web
developers.

Note that Compojure 0.4 depends on Ring, to which it delegates things like
parameter parsing and cookie manipulation.

If you're familiar with the Ruby web ecosystem: Ring : Compojure :: Rack :
Sinatra.

