Skip to content

Instantly share code, notes, and snippets.

@slipset
Created February 10, 2020 07:28
Show Gist options
  • Save slipset/c405bbb27f77eb5215eca4a365eb359a to your computer and use it in GitHub Desktop.
Save slipset/c405bbb27f77eb5215eca4a365eb359a to your computer and use it in GitHub Desktop.
(ns foo.core
(:require [ring.adapter.jetty :as jetty]))
(defn add-connection-middleware [handler uri]
(fn [req]
(let [connection (mg/connect-via-uri uri)]
(handler (assoc req :connection connection)))))
(defn handler [{:key [connection] :as request}]
{:status 200
:headers {"Content-Type" "text/html"}
:body (str "Hello World" connection)})
(jetty/run-jetty
(add-connection-middleware handler (config-keys :mongoURI))
{:port 3000})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment