diff --git a/examples/http/.gitignore b/examples/http/.gitignore new file mode 100644 index 00000000..c53038ec --- /dev/null +++ b/examples/http/.gitignore @@ -0,0 +1,11 @@ +/target +/classes +/checkouts +pom.xml +pom.xml.asc +*.jar +*.class +/.lein-* +/.nrepl-port +.hgignore +.hg/ diff --git a/examples/http/README.md b/examples/http/README.md new file mode 100644 index 00000000..3fe225c4 --- /dev/null +++ b/examples/http/README.md @@ -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 diff --git a/examples/http/project.clj b/examples/http/project.clj new file mode 100644 index 00000000..60f6406d --- /dev/null +++ b/examples/http/project.clj @@ -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}) diff --git a/examples/http/src/example/server.clj b/examples/http/src/example/server.clj new file mode 100644 index 00000000..17f4f694 --- /dev/null +++ b/examples/http/src/example/server.clj @@ -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))