diff --git a/README.md b/README.md index c1d0d86..1525c95 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,25 @@ -# Ring-Server +# Ring-Custom-Jetty-Server -A library for starting a web server to serve a [Ring][1] handler with -sensible default options and environment variable overrides. +Fork of the [ring-server][1] library. -[1]: https://github.com/ring-clojure/ring +This library changes the `ring.server.standalone/serve` function, +requiring that a function that will start an HTTP server be passed +in via the `:run-server-fn` option. In every other respect, this +library should function exactly the same as [ring-server][1]. -## Features +This function should have the same basic signature and return type +as the normal `ring.adapter.jetty/run-jetty` function used by the +[ring-server][1] library. -When starting in development mode (i.e. `LEIN_NO_DEV` is not set): +The main intended use of this library is to allow easy switching +to use an async Jetty server instead. -* The server finds a free port to start on -* It automatically reloads changed files -* It renders exceptions and their stacktraces in HTML -* A web browser is automatically opened to the started server - -In production: - -* You can specify the port via the `PORT` environment variable -* You can add hooks to run on startup and shutdown. - -## Install - -Add the following dependency to your `project.clj` file: - - [ring-server "0.3.1"] - -## Usage - -Simple usage: - -```clojure -(use 'ring.server.standalone) -(serve your-handler) -``` - -You can also specify a map of options: - -```clojure -(serve your-handler {:port 4040}) -``` - -The following options are supported: - -* `:port` - The port to start the server on, overrides `$PORT` - -* `:join?` - Whether to wait until the server stops (default true) - -* `:init` - A function executed when the server starts - -* `:destroy` - A function executed when the server stops - -* `:open-browser?` - - True if you want a browser to be opened to the server. Defaults to - true in development mode, false in production mode. - -* `:browser-uri` - - A path to append to the target URL if opening a browser (default - none). The full URI will be constructed like: - `http://{host}:{port}{browser-uri}` - -* `:stacktraces?` - - True if you want a stacktrace to be displayed in the browser when - an exception is raised. Default to true in development, false in - production. - -* `:auto-reload?` - - True if you want your source files to be automatically reloaded - when they are modified. Defaults to true in development, false in - production. - -* `:reload-paths` - - A seq of source paths to reload. Defaults to [\"src\"]. - Only relevant if :auto-reload? is true. - -* `:auto-refresh?` - - True if you want your browser to automatically refresh when source - files are changed. Defaults to false. +[1]: https://github.com/weavejester/ring-server ## License Copyright © 2013 James Reeves +Copyright © 2014 Gered King + Distributed under the Eclipse Public License, the same as Clojure. diff --git a/project.clj b/project.clj index 4729016..7f06deb 100644 --- a/project.clj +++ b/project.clj @@ -1,6 +1,6 @@ -(defproject ring-server "0.3.1" +(defproject ring-custom-jetty-server "0.1.0" :description "Library for running Ring web servers" - :url "https://github.com/weavejester/ring-server" + :url "https://github.com/gered/ring-custom-jetty-server" :license {:name "Eclipse Public License" :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.2.1"] diff --git a/src/ring/server/leiningen.clj b/src/ring_custom_jetty/server/leiningen.clj similarity index 84% rename from src/ring/server/leiningen.clj rename to src/ring_custom_jetty/server/leiningen.clj index c9e30c0..0d3a2bf 100644 --- a/src/ring/server/leiningen.clj +++ b/src/ring_custom_jetty/server/leiningen.clj @@ -1,6 +1,6 @@ -(ns ring.server.leiningen +(ns ring-custom-jetty.server.leiningen "Functions to start a server from a Leiningen plugin." - (:require [ring.server.standalone :as standalone])) + (:require [ring-custom-jetty.server.standalone :as standalone])) (defn- load-var [sym] (when sym diff --git a/src/ring/server/options.clj b/src/ring_custom_jetty/server/options.clj similarity index 93% rename from src/ring/server/options.clj rename to src/ring_custom_jetty/server/options.clj index 548b78a..48ea39b 100644 --- a/src/ring/server/options.clj +++ b/src/ring_custom_jetty/server/options.clj @@ -1,6 +1,6 @@ -(ns ring.server.options +(ns ring-custom-jetty.server.options "Functions to retrieve options and settings with sensible defaults" - (:use ring.util.environment + (:use ring-custom-jetty.util.environment [clojure.core.incubator :only (-?>)]) (:require [clojure.string :as str])) diff --git a/src/ring/server/standalone.clj b/src/ring_custom_jetty/server/standalone.clj similarity index 97% rename from src/ring/server/standalone.clj rename to src/ring_custom_jetty/server/standalone.clj index 1fb370f..5b38fbe 100644 --- a/src/ring/server/standalone.clj +++ b/src/ring_custom_jetty/server/standalone.clj @@ -1,6 +1,6 @@ -(ns ring.server.standalone +(ns ring-custom-jetty.server.standalone "Functions to start a standalone Ring server." - (:use ring.server.options + (:use ring-custom-jetty.server.options ring.middleware.stacktrace ring.middleware.reload ring.middleware.refresh diff --git a/src/ring/util/environment.clj b/src/ring_custom_jetty/util/environment.clj similarity index 89% rename from src/ring/util/environment.clj rename to src/ring_custom_jetty/util/environment.clj index dd4ea17..33d50f7 100644 --- a/src/ring/util/environment.clj +++ b/src/ring_custom_jetty/util/environment.clj @@ -1,4 +1,4 @@ -(ns ring.util.environment +(ns ring-custom-jetty.util.environment "A namespace managing and reading environment variables.") (def ^{:dynamic true, :doc "A map of environment variables."} diff --git a/test/ring/server/test/leiningen.clj b/test/ring_custom_jetty/server/test/leiningen.clj similarity index 78% rename from test/ring/server/test/leiningen.clj rename to test/ring_custom_jetty/server/test/leiningen.clj index 0caed9e..441fc61 100644 --- a/test/ring/server/test/leiningen.clj +++ b/test/ring_custom_jetty/server/test/leiningen.clj @@ -1,7 +1,7 @@ (ns ring.server.test.leiningen (:use clojure.test - ring.server.leiningen - ring.server.test.utils)) + ring-custom-jetty.server.leiningen + ring-custom-jetty.server.test.utils)) (def basic-project-clj `{:ring {:handler default-handler diff --git a/test/ring/server/test/standalone.clj b/test/ring_custom_jetty/server/test/standalone.clj similarity index 86% rename from test/ring/server/test/standalone.clj rename to test/ring_custom_jetty/server/test/standalone.clj index 16d1c8b..3b6adcc 100644 --- a/test/ring/server/test/standalone.clj +++ b/test/ring_custom_jetty/server/test/standalone.clj @@ -1,16 +1,17 @@ -(ns ring.server.test.standalone +(ns ring-custom-jetty.server.test.standalone (:use clojure.test - ring.server.standalone - ring.server.test.utils + ring-custom-jetty.server.standalone + ring-custom-jetty.server.test.utils ring.util.environment - ring.util.response)) + ring.util.response + ring.adapter.jetty)) (defn exception-handler [req] (throw (Exception. "testing"))) (defn test-server [& [{:as options}]] (let [handler (:handler options default-handler)] - (serve handler (merge {:join? false, :open-browser? false} options)))) + (serve handler (merge {:join? false, :open-browser? false :run-server-fn run-jetty} options)))) (deftest serve-test (testing "default port" diff --git a/test/ring/server/test/utils.clj b/test/ring_custom_jetty/server/test/utils.clj similarity index 93% rename from test/ring/server/test/utils.clj rename to test/ring_custom_jetty/server/test/utils.clj index 024d4ea..c7e0de0 100644 --- a/test/ring/server/test/utils.clj +++ b/test/ring_custom_jetty/server/test/utils.clj @@ -1,4 +1,4 @@ -(ns ring.server.test.utils +(ns ring-custom-jetty.server.test.utils "Utility functions for running unit tests" (:require [clj-http.client :as http]) (:use clojure.test