Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- This is the request ----
- POST /accounts HTTP/1.1
- Host: localhost:8080
- Connection: close
- Content-Length: 167
- 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
- Cache-Control: no-cache
- Origin: chrome-extension://fhbjgbiflinjbdggehcddcbncdddomop
- Content-Type: application/json
- Authorization: Token eyJhbGciOiJkaXIiLCJ0eXAiOiJKV1MiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0..oKPj2diki8MCtcG_TC5tpQ.L5pdOLOLP5tt1sUbnxV4etWy45cUIKqeKeV5PxO0_aOyWbTMJ9WSCc7QmufSI9ddkPNUh_fIB-vOxSn5ZHq5iQ.sia38TOr8xjYRbO0VQxl0w
- Postman-Token: 26479ada-5892-92ec-7758-f9e912b8f878
- Accept: */*
- DNT: 1
- Accept-Encoding: gzip, deflate
- Accept-Language: en-US,en;q=0.8
- {
- "profile" : {
- "email": "virmundi@gmail.com",
- "first-name" : "Patrick",
- "last-name" : "Davenport",
- "password" : "testing2"
- }
- }
- -- This is the clojure code ----
- (def NewProfile {:first-name s/Str,
- :last-name s/Str,
- :email Email,
- (s/optional-key :access) {:c #{s/Str},
- :r #{s/Str},
- :u #{s/Str},
- :d #{s/Str}},
- (s/optional-key :password) s/Str,
- (s/optional-key :groups) #{s/Str},
- (s/optional-key :accounts) #{s/Str}})
- (s/defschema NewAccount {:profile NewProfile})
- (defn secured-routes [profile]
- (api
- {:swagger
- {:info {:title "Secured API for handling accounts and profiles"}}}
- (GET "/profiles/:profile-key" [profile-key :as req]
- (if-let [res (only-if?
- (data/fetch-profile profile (:identity req) profile-key))]
- (ok res)
- (not-found)))
- (context "/accounts" []
- (POST "/" []
- :body [new-account NewAccount]
- :return nil
- (debug "Got " new-account " as body")
- (ok)))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement