Advertisement
Guest User

Untitled

a guest
Apr 12th, 2016
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. --- This is the request ----
  2.  
  3. POST /accounts HTTP/1.1
  4. Host: localhost:8080
  5. Connection: close
  6. Content-Length: 167
  7. User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36
  8. Cache-Control: no-cache
  9. Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
  10. Content-Type: application/json
  11. Authorization: Token eyJhbGciOiJkaXIiLCJ0eXAiOiJKV1MiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..oKPj2diki8MCtcG_TC5tpQ.L5pdOLOLP5tt1sUbnxV4etWy45cUIKqeKeV5PxO0_aOyWbTMJ9WSCc7QmufSI9ddkPNUh_fIB-vOxSn5ZHq5iQ.sia38TOr8xjYRbO0VQxl0w
  12. Postman-Token: 26479ada-5892-92ec-7758-f9e912b8f878
  13. Accept: */*
  14. DNT: 1
  15. Accept-Encoding: gzip, deflate
  16. Accept-Language: en-US,en;q=0.8
  17.  
  18. {
  19. "profile" : {
  20. "email": "virmundi@gmail.com",
  21. "first-name" : "Patrick",
  22. "last-name" : "Davenport",
  23. "password" : "testing2"
  24. }
  25. }
  26.  
  27.  
  28. -- This is the clojure code ----
  29.  
  30. (def NewProfile {:first-name s/Str,
  31. :last-name s/Str,
  32. :email Email,
  33. (s/optional-key :access) {:c #{s/Str},
  34. :r #{s/Str},
  35. :u #{s/Str},
  36. :d #{s/Str}},
  37. (s/optional-key :password) s/Str,
  38. (s/optional-key :groups) #{s/Str},
  39. (s/optional-key :accounts) #{s/Str}})
  40. (s/defschema NewAccount {:profile NewProfile})
  41.  
  42. (defn secured-routes [profile]
  43. (api
  44. {:swagger
  45. {:info {:title "Secured API for handling accounts and profiles"}}}
  46.  
  47. (GET "/profiles/:profile-key" [profile-key :as req]
  48. (if-let [res (only-if?
  49. (data/fetch-profile profile (:identity req) profile-key))]
  50. (ok res)
  51. (not-found)))
  52.  
  53. (context "/accounts" []
  54. (POST "/" []
  55. :body [new-account NewAccount]
  56. :return nil
  57. (debug "Got " new-account " as body")
  58. (ok)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement