Jelajahi Sumber

added web-backend with http-kit server

Harlan Iverson 9 tahun lalu
induk
melakukan
eeaf27956d

+ 10 - 0
web-backend/project.clj

@@ -0,0 +1,10 @@
+(defproject com.analogzen.clojure-stack/web-backend "0.0.1-SNAPSHOT"
+            :dependencies [[org.clojure/clojure :clj1.8]
+                           [ring "1.4.0"]
+                           [com.analogzen.clojure-stack/web-client "0.0.1-SNAPSHOT"]
+                           [http-kit "2.1.18"]]
+            :plugins [[lein-modules "0.3.11"]]
+
+            :main example.main
+
+            :profiles {:uberjar {:aot :all}})

+ 17 - 0
web-backend/src/example/core.clj

@@ -0,0 +1,17 @@
+(ns example.core
+    (:require [ring.middleware.resource :refer [wrap-resource]]
+              [org.httpkit.server :refer [run-server]]))
+
+(defn say-hi [req] false) ;{:status 200 :body "hi" :content-type "text/plain"}
+
+(def appx (-> say-hi
+             (wrap-resource "public")))
+
+(defn app [req] {:status 200 :body "hi" :content-type "text/plain"})
+
+
+
+
+(defn start! []
+      (println "server on.")
+      (run-server app {:port 8080}))

+ 6 - 0
web-backend/src/example/main.clj

@@ -0,0 +1,6 @@
+(ns example.main
+    (:require [example.core :as core])
+    (:gen-class))
+
+(defn -main []
+      (core/start!))