compojure.core documentation

A concise syntax for generating Ring handlers.

ANY

macro

(ANY path args & body)
Generate a route that matches any method.

DELETE

macro

(DELETE path args & body)
Generate a DELETE route.

GET

macro

(GET path args & body)
Generate a GET route.

HEAD

macro

(HEAD path args & body)
Generate a HEAD route.

OPTIONS

macro

(OPTIONS path args & body)
Generate an OPTIONS route.

PATCH

macro

(PATCH path args & body)
Generate a PATCH route.

POST

macro

(POST path args & body)
Generate a POST route.

PUT

macro

(PUT path args & body)
Generate a PUT route.

context

macro

(context path args & routes)
Give all routes in the form a common path prefix and set of bindings.

The following example demonstrates defining two routes with a common
path prefix ('/user/:id') and a common binding ('id'):

  (context "/user/:id" [id]
    (GET "/profile" [] ...)
    (GET "/settings" [] ...))

defroutes

macro

(defroutes name & routes)
Define a Ring handler function from a sequence of routes. The name may
optionally be followed by a doc-string and metadata map.

let-routes

macro

(let-routes bindings & body)
Takes a vector of bindings and a body of routes. Equivalent to:
(let [...] (routes ...))

make-route

(make-route method route handler)
Returns a function that will only call the handler if the method and Clout
route match the request.

routes

(routes & handlers)
Create a Ring handler by combining several handlers into one.

routing

(routing request & handlers)
Apply a list of routes to a Ring request map.