practicalli / practicalli/clojure-web-services
Tips for developing routes and handlers in Reitit
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 16
- Forks
- 14
- PR merge metrics
- No merged PRs in 30d
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)}}]]])
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the issue's handler and routes examples, focusing on Reitit route verification, OpenAPI response keys, and the :dev-info debugging pattern. Review the repository documentation structure to determine where route and handler development tips belong. Done means adding a clear, accurate guide covering the examples and their purpose.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure, openapi
- Domain
- api, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100