SHARE
TWEET

Untitled

a guest Oct 6th, 2014 167 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.   :available-media-types ["text/html"]
  10.   :handle-ok (fn [_] (format "User info: %s" u)))
  11.  
  12. ;; set up routes to our resources
  13.  
  14. (defroutes app
  15.   (ANY "/user/:u" [u]
  16.       :allowed-methods [:get :post]
  17.       :handle-ok (fn [_] (user u))
  18.       :post! (fn [_] (format "called post with %s" u))))
  19.  
  20. (def handler
  21.   (-> 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