No edit button so I have to post again, that first example should end with 
";; (make-profile-url "John Smith") => "/John-Smith"

And to reiterate you decide what your url will look like in your template:

<a href="http://myapp.com/JohnSmith";>View John Smith's Profile</a>
or
<a href="http://myapp.com/John-Smith";>View John Smith's Profile</a>
or
<a href="http://myapp.com/john-smith";>View John Smith's Profile</a>

Then compojure + your route handler respond to the browser requesting the 
link:

;; obviously this is ALL just psedo code of the important elements to give 
you an idea
(GET "/:username" [username] (view-profile-page username)) ;; this route 
definition will handle any of the above links

;; assume you chose the last link type, in stack-overflow style. this means 
username from the route is "john-smith"
(defn view-profile-page [username]
  (let [user (db/get-user-by-username username)]
    (render-template user)))

(defn get-user-by-username [username]
  (let [no-dash (clojure.string/replace username #"-" " ") ;; munge 
username to match what is in DB
         capitalized (capitalize-words no-dash)]
    (select-user-by-name capitalized)))

So as you can see whatever link or browser request is called, compojure 
grabs that url param and passes it in.  You then modify that param to fit 
what you expect and look it up in your DB.  You were essentially working 
backwards I think.

Hope that helps!

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to