Skip to content

Instantly share code, notes, and snippets.

@jldoubleu
Last active August 29, 2022 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jldoubleu/d2f7d54d49875f0682831c792c31f7bf to your computer and use it in GitHub Desktop.
Save jldoubleu/d2f7d54d49875f0682831c792c31f7bf to your computer and use it in GitHub Desktop.
Small http-kit server using compojure for routing.
(defproject client-server "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.10.0"]
[compojure "1.6.1"]
[http-kit "2.3.0"]]
:main ^:skip-aot client-server.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})
(ns client-server.core
(:require [org.httpkit.server :as server]
[compojure.core :refer [GET defroutes]])
(:gen-class))
(defn root
[req]
{:status 200
:body "root"})
(defn testing
[req]
{:status 200
:body "testing 1...2...3..."})
(defroutes app-routes
(GET "/" [] root)
(GET "/testing" [] testing))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(server/run-server app-routes {:port 8080}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment