Skip to content

Instantly share code, notes, and snippets.

@dimovich
Last active April 28, 2018 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimovich/cca0e19dabcfffafe6cc6337da0aa3f6 to your computer and use it in GitHub Desktop.
Save dimovich/cca0e19dabcfffafe6cc6337da0aa3f6 to your computer and use it in GitHub Desktop.
{:deps
{org.clojure/clojure {:mvn/version "1.10.0-alpha4"}
ring/ring-core {:mvn/version "1.6.3"}
metosin/reitit-core {:mvn/version "0.1.1-SNAPSHOT"}
metosin/reitit-ring {:mvn/version "0.1.1-SNAPSHOT"}
http-kit {:mvn/version "2.2.0"}}}
;;
;;├── deps.edn
;;├── public
;;│   └── index.html
;;└── src
;; └── server.clj
;; Run with:
;; clj -m server
;; http://localhost:5000
;; this returns 404
;; http://localhost:5000/index.html
<!DOCTYPE html>
<html>
<body>
<h1>Hello</h1>
</body>
</html>
(ns server
(:require [org.httpkit.server :as httpkit]
[ring.util.response :refer [response]]
[reitit.core :as r]
[reitit.ring :as ring]))
(def reitit-app
(ring/ring-handler
(ring/router
[["/" {:get (fn [_] (response (slurp "public/index.html")))}]])
(ring/routes
(ring/create-resource-handler {:path "/"})
(ring/create-default-handler))))
(defn -main []
(httpkit/run-server reitit-app {:port 5000})
(println "started."))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment