Created
December 26, 2010 20:50
-
-
Save davidsantiago/755622 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; When the wrap! is as below, the admin functions are properly wrapped, but the | |
;; site functions will error 500 with an NPE on session.clj:47. If I comment it and | |
;; uncomment the wrap! at the bottom, then the site URLs will work, but the admin | |
;; functions will not successfully log in, despite having the form parameters and | |
;; session in apparently the correct place. In fact, the post request to login is | |
;; identical in both cases, but it will only work if the code is as below. | |
;; | |
;; Ideally, I'd like to be able to break my routes into manageable chunks, compose | |
;; them, and then just wrap! once. In my reading of the source, I thought routes | |
;; were just functions that take a request and return a response, so shouldn't | |
;; you be able to wrap! them at any level? | |
(defroutes site-admin | |
(GET "/admin" {:as req} (admin/admin-home req)) | |
(GET "/admin/login" {:as req} (admin/admin-login req)) | |
(POST "/admin/login" {:as req} (admin/process-login req)) | |
(GET "/admin/createPost" {:as req} (admin/create-post-form req)) | |
(POST "/admin/createPost" {:as req} (admin/process-create-post req)) | |
(GET "/admin/logout" {:as req} (admin/process-logout req))) | |
(wrap! site-admin | |
:params | |
:keyword-params | |
print-debug | |
(wrap-session {:cookie-attrs {:domain ".davidsantiago.com"} | |
:cookie-name "session" | |
:store session-store}) | |
remove-ending-slash) | |
(defroutes site | |
(GET "/post/:post-id" [post-id] (posts/post-view post-id))) | |
(defroutes site-web | |
site-admin | |
site | |
(not-found (html [:h1 "Page not found."]))) | |
(comment (wrap! site-web | |
; :params | |
; :keyword-params | |
print-debug | |
(wrap-session {:cookie-attrs {:domain ".davidsantiago.com"} | |
:cookie-name "session" | |
:store session-store}) | |
remove-ending-slash)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment