Skip to content

Commit

Permalink
HTTP libraries compile now
Browse files Browse the repository at this point in the history
  • Loading branch information
weavejester committed Jan 18, 2009
1 parent bc34158 commit b538eff
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
9 changes: 5 additions & 4 deletions src/compojure/http/helpers.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
;;
;; Helper functions for things like redirection, serving files, 404s, etc.

(ns compojure.http.helper
(:use compojure.str-utils :only [str*])
(:import java.io.File))
(ns compojure.http.helpers
(:use [compojure.str-utils :only (str*)])
(:import java.io.File)
(:import javax.servlet.http.Cookie))

(defn redirect-to
"A shortcut for a '302 Moved' HTTP redirect."
Expand All @@ -24,7 +25,7 @@
([]
(page-not-found "public/404.html"))
([filename]
[404 (file filename)]))
[404 (File. filename)]))

(defn- find-index-file
"Search the directory for index.*"
Expand Down
2 changes: 1 addition & 1 deletion src/compojure/http/routes.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
;; keyword :next if they don't match.

(ns compojure.http.routes
(:use compojure.str-utils :only [re-escape]))
(:use [compojure.str-utils :only (re-escape)]))

;; Functions for lexing a string

Expand Down
28 changes: 15 additions & 13 deletions src/compojure/http/servlet.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
;; Functions for interfacing Compojure with the Java servlet standard.

(ns compojure.http.servlet
(:use compojure.file-utils :only [copy-stream])
(:use compojure.http.routes :only [combine-routes])
(:use [compojure.file-utils :only (copy-stream)])
(:use [compojure.http.routes :only (combine-routes)])
(:import java.io.File)
(:import java.io.InputStream)
(:import java.net.URL)
(:import java.util.Map$Entry)
(:import javax.servlet.http.Cookie)
(:import javax.servlet.http.HttpServlet)
(:import javax.servlet.http.HttpServletRequest)
(:import javax.servlet.http.HttpServletResponse))
(:import javax.servlet.http.HttpServletResponse)
(:import javax.servlet.ServletContext))

;; Functions to pull information from the request object

Expand Down Expand Up @@ -81,16 +83,16 @@
"Adds local servlet vars to the scope given a HttpServlet and a
HttpServletRequest instance."
[[#^HttpServlet servlet, #^HttpServletRequest request] & body]
(let [~'context (.getServletContext ~servlet)
~'method (.getMethod ~request)
~'url (.getURL ~request)
~'path (.getPathInfo ~request)
~'params (get-params ~request)
~'headers (get-headers ~request)
~'mimetype (partial context-mimetype ~'context)
~'session (get-session ~request)
~'cookies (get-cookies ~request)]
(do ~@body)))
`(let [~'context (.getServletContext ~servlet)
~'method (.getMethod ~request)
~'url (.getURL ~request)
~'path (.getPathInfo ~request)
~'params (get-params ~request)
~'headers (get-headers ~request)
~'mimetype (partial context-mimetype ~'context)
~'session (get-session ~request)
~'cookies (get-cookies ~request)]
(do ~@body)))

;; Functions to set data in the response object

Expand Down

0 comments on commit b538eff

Please sign in to comment.