mirror of
https://github.com/metosin/reitit.git
synced 2025-12-18 08:51:12 +00:00
example
This commit is contained in:
parent
c1a747857f
commit
a08a4adffa
4 changed files with 53 additions and 0 deletions
11
examples/http/.gitignore
vendored
Normal file
11
examples/http/.gitignore
vendored
Normal 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
14
examples/http/README.md
Normal 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
|
||||||
6
examples/http/project.clj
Normal file
6
examples/http/project.clj
Normal 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})
|
||||||
22
examples/http/src/example/server.clj
Normal file
22
examples/http/src/example/server.clj
Normal 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))
|
||||||
Loading…
Reference in a new issue