Handler functions

A handler is a function that receives a Request Map and returns a Response Map.


(defn reply-hello [request]
  {:status 200 :body (str "Hello, " (get-in request [:params :name]))})

Additional Information

Because the handler exchanges a request for a response, it will be the last interceptor to execute.

Handler functions are wrapped into Interceptors when expanding routes. This happens because the IntoInterceptor protocol is extended to functions. The handler function is wrapped into the interceptor’s :enter function.

Handlers do not have access to the full execution context, so they cannot terminate execution or enqueue additional interceptors.

If a handler throws an exception, Pedestal catches it and begins error handling. See Error Handling for details.

See Also