Response

API

Use this function to add a HTTP header:

(add-header :x-request-id 100500)
function
uri &key (retpath (get-uri))

Adds a "retpath" GET parameter to the giving URL.

Keeps all other parameters and overwrites "retpath" parameter if it is already exists in the URL.

By default, retpath is the current page, rendered by the reblocks. This is very useful to redirect user to login page and return him to the same page where he has been before.

function
&optional (response \*response\*)
function
&optional (response \*response\*)
function
&optional (response \*response\*)
function
&optional (response \*response\*)
function
&optional (response \*response\*)
function
cookie &key (response \*response\*)

Use this function to add Set-Cookie header:

(set-cookie (list :name "user_id" :value "bob" :samesite :lax))

Cookie might include these properties:

  • domain

  • path

  • expires

  • secure

  • httponly

  • samesite

function
&optional (response \*response\*)

Returns a list with a map cookie-name -> cookie:cookie object. Odd items in this list are cookie names and even are lists with cookie parameters.

function
content &key (condition-class 'immediate-response) (code 200) content-type headers cookies-to-set

Aborts request processing by signaling an immediate-response and returns a given value as response.

HTTP code and headers are taken from CODE and CONTENT-TYPE.

By default, headers and cookies are taken from the current request, but additional headers and cookies may be provides in appropriate arguments.

function
content &key (code 200) (content-type (get-default-content-type-for-response)) (headers (get-headers))

Makes a new URL, based on the current request's URL.

If new-path can be absolute, like /logout or relative, like ./stories.

Also, it can contain a query params like /login?code=100500

function
script &optional (place :after-load)

Send JavaScript to the browser. The way of sending depends on whether the current request is via AJAX or not.

Script may be either a string or a list; if it is a list it will be compiled through Parenscript first.