Open
Description
Developing handlers - understanding data involved
Handing request debug technique - return useful information as a separate key, e.g. :dev-info to share useful information in the response to the request
(defn complete-gamer-history
"Handler function for /gamer/history/complete
Arguments:
- environment hash-map containing system configuration
Returns:
- Function that takes the ring hash-map of the http request as an argument"
[environment]
(fn [request]
(let [;; Get the Invoice
gamer (request :body-params)]
;; Ring response hash-map
{:status 200
:body {:gamer-history (complete-history gamer)
:dev-info invoice}
:headers {}}
#_())))
The routing with reitit verification and open api keys, which includes the :dev-info
key as part of the response
(defn routes
"Calls `practicalli.gameboard.api.gamer.handlers/complete-gamer-history`
The handler returns a function that takes the request as an argument"
[environment]
["/gamer" {:swagger {:tag ["Gamer API"]}}
["/history"
["/complete"
{:post
{:summary "Complete Gamer history"
:description
"Gather information from all games the Gamer has played"
;; parameters used for validation and OpenAPI documentation
:parameters
{:body
{:customer-uuid uuid?
:email string?
:first_name string?
:last_name string?
:phone_number string?
:is_existing_customer boolean?
:ip_address string?
:billing-address {:street string?
:house-number string?
:postal_code string?
:city string?
:country string?
:addition string?}
:games [{:title string?
:description string?
:software-house string?}]}}
;; responses used for validation and OpenAPI documentation
:responses {200 {:body {:is-fraud boolean?
;; :dev-info used for developer information
:dev-info map?}}
400 {:body string?}
500 {:body string?}}
:handler (handlers/complete-gamer-history environment)}}]]])