SHARE
TWEET

Untitled

a guest Oct 6th, 2014 181 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (ns cargolds.core
  2.   (:require [liberator.core :refer [resource defresource]]
  3.             [ring.middleware.params :refer [wrap-params]]
  4.             [compojure.core :refer [defroutes ANY]]))
  5.  
  6. ;; define a simple parameterized resource
  7.  
  8. (defresource user [u]
  9.   :allowed-methods [:get :post]
  10.   :available-media-types ["text/html"]
  11.   :handle-ok (fn [_] (format "User info: %s" u))
  12.   :post! (do (println "!!!") (fn [_] (format "called post with %s" u))))
  13.  
  14. ;; set up routes to our resources
  15.  
  16. (defroutes app
  17.   (ANY "/user/:u" [u] (fn [_] (user u))))
  18.  
  19. (def handler
  20.   (-> app wrap-params))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top