Skip to content

Commit 4fa81c4

Browse files
committed
[housekeeping] more docs
1 parent c6cd2cc commit 4fa81c4

File tree

4 files changed

+66
-57
lines changed

4 files changed

+66
-57
lines changed

.github/workflows/ci.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66

77
name: Tests
88

9-
on: [push]
9+
on:
10+
push:
11+
paths-ignore:
12+
- "**.md"
1013

1114
jobs:
1215
build:

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018-2022 Rahul De
3+
Copyright (c) 2020- Rahul De
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 59 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,15 @@ components:
118118
A clojure map of OperationId to handler fns:
119119
```clojure
120120
(def handlers
121-
{"AddGet" (fn [{{{:keys [n1 n2]} :path} :parameters}]
122-
{:status 200
123-
:body (str (+ n1 n2))})
124-
"AddPost" (fn [{{{:keys [n1 n2]} :body} :parameters}]
125-
{:status 200
126-
:body (str (+ n1 n2))})
121+
{"AddGet" (fn [{{{:keys [n1 n2]} :path} :parameters}]
122+
{:status 200
123+
:body (str (+ n1 n2))})
124+
"AddPost" (fn [{{{:keys [n1 n2]} :body} :parameters}]
125+
{:status 200
126+
:body (str (+ n1 n2))})
127127
"HealthCheck" (fn [_]
128128
{:status 200
129-
:body "Ok"})})
129+
:body "Ok"})})
130130
```
131131

132132
Generate the routes:
@@ -156,58 +156,64 @@ Generate the routes:
156156

157157
Bootstrapping a Jetty server:
158158
```clojure
159-
(ns server
160-
(:require [muuntaja.core :as m]
161-
[reitit.ring :as ring]
162-
[reitit.http :as http]
163-
[reitit.coercion.malli :as malli]
164-
[reitit.http.coercion :as coercion]
165-
[reitit.http.interceptors.parameters :as parameters]
166-
[reitit.http.interceptors.muuntaja :as muuntaja]
167-
[reitit.interceptor.sieppari :as sieppari]
168-
[ring.adapter.jetty :as jetty]
169-
[navi.core :as navi]))
159+
(ns server.main
160+
(:require
161+
[muuntaja.core :as m]
162+
[navi.core :as navi]
163+
[reitit.coercion.malli :as malli]
164+
[reitit.http :as http]
165+
[reitit.http.coercion :as coercion]
166+
[reitit.http.interceptors.exception :as exception]
167+
[reitit.http.interceptors.muuntaja :as muuntaja]
168+
[reitit.http.interceptors.parameters :as parameters]
169+
[reitit.interceptor.sieppari :as sieppari]
170+
[reitit.ring :as ring]
171+
[ring.adapter.jetty :as jetty])
172+
(:gen-class))
170173

171174
(def server
172175
(http/ring-handler
173-
(http/router (-> "api.yaml"
174-
slurp
175-
(navi/routes-from handlers)) ; handlers is the map described before
176-
{:data {:coercion malli/coercion
177-
:muuntaja m/instance
178-
:interceptors [(parameters/parameters-interceptor)
179-
(muuntaja/format-negotiate-interceptor)
180-
(muuntaja/format-response-interceptor)
181-
(exception/exception-interceptor)
182-
(muuntaja/format-request-interceptor)
183-
(coercion/coerce-exceptions-interceptor)
184-
(coercion/coerce-response-interceptor)
185-
(coercion/coerce-request-interceptor)]}})
186-
(ring/routes
187-
(ring/create-default-handler
188-
{:not-found (constantly {:status 404
189-
:headers {"Content-Type" "application/json"}
190-
:body "{\"message\": \"Took a wrong turn?\"}"})}))
191-
{:executor sieppari/executor}))
192-
193-
(jetty/run-jetty (var server)
194-
{:host "0.0.0.0"
195-
:port 7777
196-
:join? false
197-
:async? true})
176+
(http/router (-> "api.yaml"
177+
slurp
178+
(navi/routes-from handlers)) ; handlers is the map described before
179+
{:data {:coercion malli/coercion
180+
:muuntaja m/instance
181+
:interceptors [(parameters/parameters-interceptor)
182+
(muuntaja/format-negotiate-interceptor)
183+
(muuntaja/format-response-interceptor)
184+
(exception/exception-interceptor)
185+
(muuntaja/format-request-interceptor)
186+
(coercion/coerce-exceptions-interceptor)
187+
(coercion/coerce-response-interceptor)
188+
(coercion/coerce-request-interceptor)]}})
189+
(ring/routes
190+
(ring/create-default-handler
191+
{:not-found (constantly {:status 404
192+
:headers {"Content-Type" "application/json"}
193+
:body "{\"message\": \"Took a wrong turn?\"}"})}))
194+
{:executor sieppari/executor}))
195+
196+
(defn -main
197+
[& _]
198+
(jetty/run-jetty (var server)
199+
{:host "0.0.0.0"
200+
:port 7777
201+
:join? false
202+
:async? true}))
198203
```
199204

200205
deps.edn used for this example:
201206
```edn
202207
{:deps {org.clojars.lispyclouds/navi {:mvn/version "0.0.2"}
203-
metosin/reitit-core {:mvn/version "0.6.0"}
204-
metosin/reitit-http {:mvn/version "0.6.0"}
205-
metosin/reitit-interceptors {:mvn/version "0.6.0"}
206-
metosin/reitit-malli {:mvn/version "0.6.0"}
207-
metosin/reitit-ring {:mvn/version "0.6.0"}
208-
metosin/reitit-sieppari {:mvn/version "0.6.0"}
209-
metosin/muuntaja {:mvn/version "0.6.8"}
210-
ring/ring-jetty-adapter {:mvn/version "1.9.2"}}}
208+
metosin/reitit-core {:mvn/version "0.6.0"}
209+
metosin/reitit-http {:mvn/version "0.6.0"}
210+
metosin/reitit-interceptors {:mvn/version "0.6.0"}
211+
metosin/reitit-malli {:mvn/version "0.6.0"}
212+
metosin/reitit-ring {:mvn/version "0.6.0"}
213+
metosin/reitit-sieppari {:mvn/version "0.6.0"}
214+
metosin/reitit-middleware {:mvn/version "0.6.0"}
215+
metosin/muuntaja {:mvn/version "0.6.8"}
216+
ring/ring-jetty-adapter {:mvn/version "1.9.6"}}}
211217
```
212218

213219
### Build Requirements
@@ -219,6 +225,6 @@ deps.edn used for this example:
219225

220226
## License
221227

222-
Copyright © 2020-2021 Rahul De
228+
Copyright © 2020- Rahul De
223229

224-
Distributed under the EPL License, same as Clojure. See LICENSE.
230+
Distributed under the MIT License. See LICENSE.

project.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
:author "Rahul De <[email protected]>"
99
:url "https://github.com/lispyclouds/navi"
1010
:description "A tiny library converting OpenAPI route definitions to Reitit routes."
11-
:license {:name "EPL 1.0"
12-
:url "http://opensource.org/licenses/eclipse-1.0.php"}
11+
:license {:name "MIT"
12+
:url "https://opensource.org/licenses/MIT"}
1313
:dependencies [[io.swagger.parser.v3/swagger-parser "2.1.12"]])

0 commit comments

Comments
 (0)