Permalink
Browse files

Doc and example tweaks.

  • Loading branch information...
1 parent 7271607 commit f2f42293e86198bb2a1c6411819ded5d3d82cd35 @mmcgrana committed Feb 23, 2010
View
2 LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2009 Mark McGranaghan +Copyright (c) 2009-2010 Mark McGranaghan
Permission is hereby granted, free of charge, to any person Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation obtaining a copy of this software and associated documentation
View
14 README.markdown
@@ -18,12 +18,12 @@ A Ring handler:
Adding simple middleware: Adding simple middleware:
- (defn with-upcase [app] + (defn wrap-upcase [app]
(fn [req] (fn [req]
(let [orig-resp (app req)] (let [orig-resp (app req)]
(assoc orig-resp :body (.toUpperCase (:body orig-resp)))))) (assoc orig-resp :body (.toUpperCase (:body orig-resp))))))
- (def upcase-app (with-upcase app)) + (def upcase-app (wrap-upcase app))
(run-jetty upcase-app {:port 8080}) (run-jetty upcase-app {:port 8080})
@@ -36,15 +36,15 @@ First, pull in Ring's dependencies using [Leiningen](http://github.com/technoman
To see a live "Hello World" Ring app, run: To see a live "Hello World" Ring app, run:
- $ clj src/ring/example/hello_world.clj + $ clj example/hello_world.clj
Now visit `http://localhost:8080/` in your browser; the Ring app will respond to your request with a simple HTML page indicating the time of day. Now visit `http://localhost:8080/` in your browser; the Ring app will respond to your request with a simple HTML page indicating the time of day.
Note that your `clj` script needs to add the `src` directory and the jars in `lib` to your classpath. Note that your `clj` script needs to add the `src` directory and the jars in `lib` to your classpath.
To see a more sophisticated Ring app, run: To see a more sophisticated Ring app, run:
- $ clj src/ring/example/wrapping.clj + $ clj example/wrapping.clj
* If you request `http://localhost:8080/` in your browser the `ring.handler.dump` handler will respond with an HTML page representing the request map that it received (see the `SPEC` for details on the request map). * If you request `http://localhost:8080/` in your browser the `ring.handler.dump` handler will respond with an HTML page representing the request map that it received (see the `SPEC` for details on the request map).
* If you request `http://localhost:8080/clojure.png`, the `ring.middleware.file` middleware will detect that there is a `clojure.png` file in the app's `public` directory and return that image as a response. * If you request `http://localhost:8080/clojure.png`, the `ring.middleware.file` middleware will detect that there is a `clojure.png` file in the app's `public` directory and return that image as a response.
@@ -68,11 +68,11 @@ Included Libs
Development Development
----------- -----------
-Ring is being actively developed; you can track its progress and contribute at the project's [GitHub](http://github.com/mmcgrana/ring) page. +Ring is being actively developed; you can track its progress and contribute at the project's [GitHub page](http://github.com/mmcgrana/ring) and [Google Group](http://groups.google.com/group/ring-clojure).
To run all the Ring unit tests: To run all the Ring unit tests:
- $ clj test/ring/run.clj + $ lein test
Thanks Thanks
------ ------
@@ -82,6 +82,6 @@ This project borrows heavily from Ruby's Rack and Python's WSGI, and I thank the
License License
------- -------
-Copyright (c) 2009 Mark McGranaghan and released under an MIT license. +Copyright (c) 2009-2010 Mark McGranaghan and released under an MIT license.
Clojure logo by Tom Hickey. Clojure logo by Tom Hickey.
View
5 example/hello_world.clj
@@ -4,14 +4,13 @@
(:use ring.adapter.jetty) (:use ring.adapter.jetty)
(:import java.util.Date java.text.SimpleDateFormat)) (:import java.util.Date java.text.SimpleDateFormat))
-(def formatter (SimpleDateFormat. "HH:mm:ss"));
-
(defn app (defn app
[req] [req]
{:status 200 {:status 200
:headers {"Content-Type" "text/html"} :headers {"Content-Type" "text/html"}
:body (str "<h3>Hello World from Ring</h3>" :body (str "<h3>Hello World from Ring</h3>"
"<p>The current time is " "<p>The current time is "
- (.format formatter (Date.)) ".</p>")}) + (.format (SimpleDateFormat. "HH:mm:ss") (Date.))
+ ".</p>")})
(run-jetty app {:port 8080}) (run-jetty app {:port 8080})
View
8 example/linted.clj
@@ -13,9 +13,9 @@
wrap-lint wrap-lint
wrap-file-info wrap-file-info
wrap-lint wrap-lint
- (wrap-file "src/ring/example/public") + (wrap-file "example/public")
wrap-lint wrap-lint
- (wrap-reload '(ring.dump) + (wrap-reload '(ring.handler.dump))
- wrap-lint))) + wrap-lint))
-(run-jetty app {:port 8080}) +(run-jetty app {:port 8080})
View
BIN example/public/clojure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
2 example/wrapping.clj
@@ -15,7 +15,7 @@
(def app (def app
(-> handle-dump (-> handle-dump
wrap-error wrap-error
- (wrap-file "src/ring/example/public") + (wrap-file "example/public")
wrap-file-info wrap-file-info
wrap-stacktrace)) wrap-stacktrace))
View
2 src/ring/middleware/file_info.clj
@@ -60,7 +60,7 @@
(defn- get-extension (defn- get-extension
"Returns the file extension of a file." "Returns the file extension of a file."
- [file] + [#^File file]
(second (re-find #"\.([^./\\]+)$" (.getPath file)))) (second (re-find #"\.([^./\\]+)$" (.getPath file))))
(defn- guess-mime-type (defn- guess-mime-type

0 comments on commit f2f4229

Please sign in to comment.