Skip to content

How to generate a url using url for

macourtney edited this page Sep 13, 2010 · 3 revisions

Added for version: 0.4
Updated for version: 0.7

If you don’t need to create a link or a form, but do need to generate a url from a request-map, you can use the url-for function from the conjure.core.view.util namespace.

To get the url for your current controller and action use:

(url-for)

For a url to an action, say ‘list’, in the same controller use:

(url-for { :action "list" })

For a url to an action, say ‘list’, in a different controller, ‘message’, use:

(url-for { :controller "message", :action "list" })

For a url with the parameter :id with value 1 use:

(url-for { :params { :id 1 } })

To set the server name use:

(url-for { :server-name "www.google.com" })

You can change the scheme to ‘ftp’ with:

(url-for { :scheme "ftp" })

To set the user to ‘me’ and password to ‘letmein’:

(url-for { :user "me", :password "letmein" })

To set the port to 1234:

(url-for { :port 1234 })

Add an anchor named “show-me”:

(url-for { :anchor "show-me" })
Clone this wiki locally