This commit is contained in:
Tommi Reiman 2018-08-20 18:48:22 +03:00
parent c1a747857f
commit a08a4adffa
4 changed files with 53 additions and 0 deletions

11
examples/http/.gitignore vendored Normal file
View file

@ -0,0 +1,11 @@
/target
/classes
/checkouts
pom.xml
pom.xml.asc
*.jar
*.class
/.lein-*
/.nrepl-port
.hgignore
.hg/

14
examples/http/README.md Normal file
View file

@ -0,0 +1,14 @@
# Http with Swagger example
## Usage
```clj
> lein repl
(start)
```
Go with browser to http://localhost:3000
## License
Copyright © 2018 Metosin Oy

View file

@ -0,0 +1,6 @@
(defproject ring-example "0.1.0-SNAPSHOT"
:description "Reitit Ring App with Swagger"
:dependencies [[org.clojure/clojure "1.9.0"]
[ring "1.6.3"]
[metosin/reitit "0.2.0-SNAPSHOT"]]
:repl-options {:init-ns example.server})

View file

@ -0,0 +1,22 @@
(ns example.server
(:require [reitit.http :as http]
[reitit.ring :as ring]
[reitit.interceptor.sieppari]
[ring.adapter.jetty :as jetty]))
(def app
(http/ring-handler
(http/router
["/" {:get (fn [request]
{:status 200
:body "hello!"})}])
(ring/routes
(ring/create-default-handler))
{:executor reitit.interceptor.sieppari/executor}))
(defn start []
(jetty/run-jetty #'app {:port 3000, :join? false, :async? true})
(println "server running in port 3000"))
(comment
(start))