Common Lisp Package: CLACK.MIDDLEWARE.POSTMODERN

# Clack.Middleware.Postmodern - Middleware for Postmodern connection management ## SYNOPSIS (builder (<clack-middleware-postmodern> :database "database-name" :user "database-user" :password "database-password" :host "remote-address") app) ## DESCRIPTION This is a Clack Middleware component for managing Postmodern connections. The database connection will be bound to postmodern:*database* as expected by most of the postmodern functionality. Additionally it can be found in the environment under the key :clack.postmodern.databases in form of an list that maps the database names to the connections. This allows the connection to multiple databases. The connections can be retrieved by calling (get-connection db-name env). ## Slots * database (String) The name of the database. * user (String) The database user name. * password (String) The password to the database. * host (Optional, String) The address of the database server. The default is "localhost" * port (Optional, Integer) The port on which the database server is listening. * pooled-p (Optional, Boolean) If true, then the connection pool is used. The default is true. * use-ssl (Optional, Keyword) Same meaning as in the connection spec to a postmodern database. ## AUTHOR * Karl Heinrichmeyer (karl.heinrichmeyer@gmail.com) ## SEE ALSO * [Postmodern](http://marijnhaverbeke.nl/postmodern/)

README:

FUNCTION

Public

Undocumented

GET-CONNECTION (DB-NAME ENV)

MACRO

Private

WITH-CONNECTION (SPEC &BODY BODY)

Locally establish a database connection, and bind *database* to it.

SLOT-ACCESSOR

Private

DATABASE (OBJECT)

The name of the database to connect to.

SETFDATABASE (NEW-VALUE OBJECT)

The name of the database to connect to.

HOST (OBJECT)

The host the database server is on.

SETFHOST (NEW-VALUE OBJECT)

The host the database server is on.

PASSWORD (OBJECT)

The password for the database.

SETFPASSWORD (NEW-VALUE OBJECT)

The password for the database.

POOLED-P (OBJECT)

Shall the connections be pooled?

SETFPOOLED-P (NEW-VALUE OBJECT)

Shall the connections be pooled?

PORT (OBJECT)

The port the database server is listening on.

SETFPORT (NEW-VALUE OBJECT)

The port the database server is listening on.

USE-SSL (OBJECT)

Keyword for the use-ssl configuration.

SETFUSE-SSL (NEW-VALUE OBJECT)

Keyword for the use-ssl configuration.

USER (OBJECT)

The name of the database user.

SETFUSER (NEW-VALUE OBJECT)

The name of the database user.

VARIABLE

Private

*DATABASE*

Special holding the current database. Most functions and macros operating on a database assume this contains a connected database.

CLASS

Public

<CLACK-MIDDLEWARE-POSTMODERN>

This middleware opens a connection to the specified database and stores it in *database* as expected by postmodern. It also stores the connection(s) in an alist (database name as key) in the environment with the key :clack.postmodern.databases.