(ns jugsclojure.server
  (:require [clojure.java.io :as io]
            [compojure.core :refer [ANY GET PUT POST DELETE defroutes]]
            [compojure.route :refer [resources]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ring.middleware.gzip :refer [wrap-gzip]]
            [ring.middleware.logger :refer [wrap-with-logger]]
            [environ.core :refer [env]]
            [ring.adapter.jetty :refer [run-jetty]])
  (:gen-class))

(defroutes routes
  (GET "/" _
    {:status 200
     :headers {"Content-Type" "text/html; charset=utf-8"}
     :body (io/input-stream (io/resource "public/index.html"))})
  (resources "/"))

(def http-handler
  (-> routes
      (wrap-defaults api-defaults)
      wrap-with-logger
      wrap-gzip))


(defonce server (atom nil))

(defn restart-server [& [port]]
  (swap! server (fn [value]
                  (when value (.stop value))
                  (run-jetty #'http-handler {:port (or port 10555) :join? false}))))

(defn -main [& [port]]
  (let [port (Integer. (or port (env :port)))]
    (restart-server port)))
(ns jugsclojure.server
  (:require [clojure.java.io :as io]
            [compojure.core :refer [ANY GET PUT POST DELETE defroutes]]
            [compojure.route :refer [resources]]
            [ring.middleware.defaults :refer [wrap-defaults api-defaults]]
            [ring.middleware.gzip :refer [wrap-gzip]]
            [ring.middleware.logger :refer [wrap-with-logger]]
            [environ.core :refer [env]]
            [ring.adapter.jetty :refer [run-jetty]])
  (:gen-class))

(defroutes routes
  (GET "/" _
    {:status 200
     :headers {"Content-Type" "text/html; charset=utf-8"}
     :body (io/input-stream (io/resource "public/index.html"))})
  (resources "/"))

(def http-handler
  (-> routes
      (wrap-defaults api-defaults)
      wrap-with-logger
      wrap-gzip))


(defonce server (atom nil))

(defn restart-server [& [port]]
  (swap! server (fn [value]
                  (when value (.stop value))
                  (run-jetty #'http-handler {:port (or port 10555) :join? false}))))

(defn -main [& [port]]
  (let [port (some-> (or port (env :port)) (Integer.))]
    (restart-server port)))

Fix command line port handling
Fix command line port handling

ordnungswidrig/jugs-clojure