The easy-routes Reference Manual

Next: , Previous: , Up: (dir)   [Contents][Index]

The easy-routes Reference Manual

This is the easy-routes Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 04:28:55 2022 GMT+0.

Table of Contents


1 Introduction

EASY-ROUTES

EASY-ROUTES is yet another routes handling system on top of Hunchentoot.

It's just glue code for Restas routing subsystem (CL-ROUTES).

It supports:

Usage

Use routes-acceptor acceptor:

(hunchentoot:start (make-instance 'easy-routes:routes-acceptor))

Note that the routes-acceptor returns with HTTP not found if no route matches and doesn't fallback to easy-handlers, and so it doesn't iterate over Hunchentoot *dispatch-table*. Most of the time, that iteration is a useful thing, so you may want to start the easy-routes:easy-routes-acceptor instead, that inherits from Hunchentoot easy-acceptor and so it iterates the dispatch table if no route matches (useful for being able to use define-easy-handler and also handling static files).

Routes

Syntax


(defroute <name> (<path> &rest <route-options>) <route-params> 
   &body body)
   

with:

Example route

(defroute foo ("/foo/:arg1/:arg2" :method :get
                                  :decorators (@auth @db @html))
   (&get w)
    (format nil "<h1>FOO arg1: ~a arg2: ~a ~a</h1>" arg1 arg2 w))

Url generation

Use genurl function with the name of the route and route parameters as keyword arguments to generate urls.

Example:

(genurl 'save-payment-form :id (id application))

Decorators

Decorators are functions that are executed before the route body. They should call the next parameter function to continue executing the decoration chain and the route body finally.

Examples

(defun @auth (next)
  (let ((*user* (hunchentoot:session-value 'user)))
    (if (not *user*)
	(hunchentoot:redirect "/login")
	(funcall next))))

(defun @html (next)
  (setf (hunchentoot:content-type*) "text/html")
  (funcall next))

(defun @json (next)
  (setf (hunchentoot:content-type*) "application/json")
  (funcall next))

(defun @db (next)
  (postmodern:with-connection *db-spec*
    (funcall next)))

Decorators also support parameters, like in the @check and @check-permission decorators:

(defun @check (predicate http-error next)
  (if (funcall predicate)
      (funcall next)
      (http-error http-error)))

(defun @check-permission (predicate next)
  (if (funcall predicate)
      (funcall next)
      (permission-denied-error)))

Then you can use those decorators passing the needed parameters. predicate and http-error for @check, and predicate for check permission:

(defroute my-protected-route ("/foo" :method :get
                                     :decorators ((@check my-permissions-checking-function hunchentoot:+http-forbidden+)))
   ()			      
   ...)

Routes for individual acceptors

By default routes are registered globally in *ROUTES* and *ROUTES-MAPPER* variables. That is convenient for the most common case of running a single EASY-ROUTES service per Lisp image.

But it gets problematic if you want to run several EASY-ROUTES based services on the same Lisp image. If routes are registered globally, then all your acceptors use the same routes and mapper; that means that a service A would also respond to routes defined in service B; that's clearly not what you want.

For that case, you can use acceptor names to define routes for a specific acceptor.

First you need to give your acceptor a name, using :name acceptor parameter:

(hunchentoot:start (make-instance 'easy-routes:routes-acceptor :name 'my-service))

Then, use that name in routes definition :acceptor-name:

(defroute my-route ("/my-route" :acceptor-name my-service)
  ...
)

Now my-route is registered locally to the my-service acceptor; other running EASY-ROUTES acceptors don't have it in their map anymore. That means you can run several EASY-ROUTES acceptors at the same time on the same Lisp image now.

Lastly, you need to use :acceptor-name when generating urls now too:

(genurl 'my-route :acceptor-name 'my-service)

Map of routes visualization

CL-ROUTES package implement special SWANK code for routes map visualization. Just inspect *ROUTES-MAP* variable from your lisp listener.

For example:

#<ROUTES:MAPPER {1007630E53}>
--------------------

Tree of routes
--------------------------------------------------

users invoice-engine::admin/users
api/invoices/chart invoice-engine::invoices-chart-data
invoice-engine::dashboard
logout invoice-engine::logout
company/logo invoice-engine::company-logo
search invoice-engine::global-search
preview-invoice invoice-engine::preview-invoice
dt-invoices invoice-engine::datatables-list-invoices
tenants invoice-engine::admin/tenants
admin/
    settings invoice-engine::admin/settings
    invoice-engine::admin/dashboard
    tenants/new/
        invoice-engine::admin/tenants/create
        invoice-engine::admin/tenants/new
    login/
        invoice-engine::admin/signin
        invoice-engine::admin/login
    tenant/$id invoice-engine::admin/tenant
    users/
        new/
            invoice-engine::admin/users/create
            invoice-engine::admin/users/new
        $id/edit/
            invoice-engine::admin/users/update
            invoice-engine::admin/users/edit
customers/
    invoice-engine::web/list-customers
    $id invoice-engine::view-customer
invoices/
    invoice-engine::list-invoices-route
    $id/
        print invoice-engine::web/print-invoice
        printed invoice-engine::web/printed-invoice
        invoice-engine::view-invoice
        send invoice-engine::web/send-invoice-by-email

Less fancy, but useful too, you can also use (describe easy-routes:*routes-mapper*) to visualize the tree of routes.

Augmented error pages and logs

You can get augmented error pages and logs with request, session and route information, adding easy-routes+errors as dependency, and subclassing from easy-routes-errors-acceptor, like:

(defclass my-acceptor (easy-routes:easy-routes-acceptor easy-routes::easy-routes-errors-acceptor)
  ())

This is implemented with hunchentoots-errors library.

Djula integration

easy-routes+djula system implements support for generating easy-routes urls using route names and arguments in Djula templates (calls genurl function).

Djula template syntax:

{% genurl route-name &rest args %}

Example:

{% genurl my-route :id 22 :foo template-var.key %}

Reference

Functions

@html

(next)

HTML decoration. Sets reply content type to text/html

find-route

(name)

Find a route by name (symbol)

genurl

(route-symbol &rest args &key &allow-other-keys)

Generate a relative url from a route name and arguments

genurl*

(route-symbol &rest args &key &allow-other-keys)

Generate an absolute url from a route name and arguments

redirect

(route-symbol &rest args)

Redirect to a route url. Pass the route name and the parameters.

Macros

defroute

(name template-and-options params &body body)

Route definition syntax

Classes

easy-routes-acceptor

This acceptor tries to match and handle easy-routes first, but fallbacks to easy-routes dispatcher if there's no matching

routes-acceptor

This acceptors handles routes and only routes. If no route is matched then an HTTP NOT FOUND error is returned. If you want to use Hunchentoot easy-handlers dispatch as a fallback, use EASY-ROUTES-ACCEPTOR


2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 easy-routes

Yet another routes handling utility on top of Hunchentoot

Author

Mariano Montone <marianomontone@gmail.com>

Home Page

https://github.com/mmontone/easy-routes

License

MIT

Long Description

# EASY-ROUTES #

EASY-ROUTES is yet another routes handling system on top of Hunchentoot.

It’s just glue code for Restas routing subsystem (CL-ROUTES).

It supports:

* Dispatch based on HTTP method
* Arguments extraction from the url path
* Decorators
* Url generation from route names

## Usage ##

Use ‘routes-acceptor‘ acceptor:

“‘lisp
(hunchentoot:start (make-instance ’easy-routes:routes-acceptor))
“‘

Note that the ‘routes-acceptor‘ returns with HTTP not found if no route matches and doesn’t fallback to ‘easy-handlers‘, and so it doesn’t iterate over Hunchentoot ‘*dispatch-table*‘. Most of the time, that iteration is a useful thing, so you may want to start the ‘easy-routes:easy-routes-acceptor‘ instead, that inherits from Hunchentoot ‘easy-acceptor‘ and so it iterates the dispatch table if no route matches (useful for being able to use ‘define-easy-handler‘ and also handling static files).

## Routes ##

### Syntax ###

“‘lisp

(defroute <name> (<path> &rest <route-options>) <route-params>
&body body)

“‘

with:

* ‘path‘: A string with an url path that can contain arguments prefixed with a colon.
Like ‘"/foo/:x/:y"‘, where ‘:x‘ and ‘:y‘ are bound into x and y variables in the context of the route body.
* ‘route-options‘: possible options are
* ‘:method‘ - The HTTP method to dispatch, as a keyword. Default is ‘:get‘.
* ‘:decorators‘ - The decorators to attach (see "decorators" section below).
* ‘:acceptor-name‘ - The name of the acceptor the route should be added to (optional).
* ‘route-params‘: a list of params to be extracted from the url or HTTP request body (POST).
Has this form: ‘(params &get get-params &post post-params &path path-params)‘, with the ‘&get‘, ‘&post‘ and ‘&path‘ params sections being optional, and where ‘params‘ are grabbed via ‘hunchentoot:parameter‘ function, ‘get-params‘ via ‘hunchentoot:get-parameter‘ function, and ‘post-params‘ via ‘hunchentoot:post-parameter‘ function. ‘path-params‘ specifies the type of params in the url path (see below for an example).

For example:

“‘lisp
(easy-routes:defroute name ("/foo/:x") (y &get z)
(format nil "x: ~a y: ~a z: ~a" x y z))
“‘
Also, params can have Hunchentoot easy-handler style options, described here: http://weitz.de/hunchentoot/#define-easy-handler

“‘
(var &key real-name parameter-type init-form request-type)
“‘

For example:

“‘lisp
(easy-routes:defroute foo "/foo/:x"
((y :real-name "Y" :init-form 22 :parameter-type ’integer))
(format nil "~A - ~A" x y))
“‘

You can also specify the type of path parameters after ‘&path‘. For example, say you want to sum a path argument to a query argument. You can specify their type as ’INTEGER and calculate their sum without parsing:

“‘lisp
(easy-routes:defroute foo "/foo/:x"
((y :init-form 10 :parameter-type ’integer)
&path (x ’integer))
(format nil "~A" (+ x y)))
“‘

### Example route ###

“‘lisp
(defroute foo ("/foo/:arg1/:arg2" :method :get
:decorators (@auth @db @html))
(&get w)
(format nil "<h1>FOO arg1: ~a arg2: ~a ~a</h1>" arg1 arg2 w))
“‘
## Url generation

Use ‘genurl‘ function with the name of the route and route parameters as keyword arguments to generate urls.

Example:

“‘lisp
(genurl ’save-payment-form :id (id application))
“‘

## Decorators ##

Decorators are functions that are executed before the route body. They should call the ‘next‘ parameter function to continue executing the decoration chain and the route body finally.

### Examples ###

“‘lisp
(defun @auth (next)
(let ((*user* (hunchentoot:session-value ’user)))
(if (not *user*)
(hunchentoot:redirect "/login")
(funcall next))))

(defun @html (next)
(setf (hunchentoot:content-type*) "text/html")
(funcall next))

(defun @json (next)
(setf (hunchentoot:content-type*) "application/json")
(funcall next))

(defun @db (next)
(postmodern:with-connection *db-spec*
(funcall next)))
“‘

Decorators also support parameters, like in the ‘@check‘ and ‘@check-permission‘ decorators:

“‘lisp
(defun @check (predicate http-error next)
(if (funcall predicate)
(funcall next)
(http-error http-error)))

(defun @check-permission (predicate next)
(if (funcall predicate)
(funcall next)
(permission-denied-error)))
“‘

Then you can use those decorators passing the needed parameters. ‘predicate‘ and ‘http-error‘ for ‘@check‘,
and ‘predicate‘ for check permission:

“‘lisp
(defroute my-protected-route ("/foo" :method :get
:decorators ((@check my-permissions-checking-function hunchentoot:+http-forbidden+)))
()
...)
“‘

## Routes for individual acceptors

By default routes are registered globally in ‘*ROUTES*‘ and ‘*ROUTES-MAPPER*‘ variables.
That is convenient for the most common case of running a single EASY-ROUTES service per Lisp image.

But it gets problematic if you want to run several EASY-ROUTES based services on the same Lisp image.
If routes are registered globally, then all your acceptors use the same routes and mapper;
that means that a service A would also respond to routes defined in service B; that’s clearly not what you want.

For that case, you can use ‘acceptor names‘ to define routes for a specific acceptor.

First you need to give your acceptor a name, using ‘:name‘ acceptor parameter:

“‘lisp
(hunchentoot:start (make-instance ’easy-routes:routes-acceptor :name ’my-service))
“‘

Then, use that name in routes definition ‘:acceptor-name‘:

“‘lisp
(defroute my-route ("/my-route" :acceptor-name my-service)
...
)
“‘

Now ‘my-route‘ is registered locally to the ‘my-service‘ acceptor; other running EASY-ROUTES acceptors don’t have it in their map anymore.
That means you can run several EASY-ROUTES acceptors at the same time on the same Lisp image now.

Lastly, you need to use ‘:acceptor-name‘ when generating urls now too:

“‘lisp
(genurl ’my-route :acceptor-name ’my-service)
“‘
## Map of routes visualization

CL-ROUTES package implement special SWANK code for routes map visualization. Just inspect ‘*ROUTES-MAP*‘ variable from your lisp listener.

For example:

“‘
#<ROUTES:MAPPER {1007630E53}>
——————–

Tree of routes
————————————————–

users invoice-engine::admin/users
api/invoices/chart invoice-engine::invoices-chart-data
invoice-engine::dashboard
logout invoice-engine::logout
company/logo invoice-engine::company-logo
search invoice-engine::global-search
preview-invoice invoice-engine::preview-invoice
dt-invoices invoice-engine::datatables-list-invoices
tenants invoice-engine::admin/tenants
admin/
settings invoice-engine::admin/settings
invoice-engine::admin/dashboard
tenants/new/
invoice-engine::admin/tenants/create
invoice-engine::admin/tenants/new
login/
invoice-engine::admin/signin
invoice-engine::admin/login
tenant/$id invoice-engine::admin/tenant
users/
new/
invoice-engine::admin/users/create
invoice-engine::admin/users/new
$id/edit/
invoice-engine::admin/users/update
invoice-engine::admin/users/edit
customers/
invoice-engine::web/list-customers
$id invoice-engine::view-customer
invoices/
invoice-engine::list-invoices-route
$id/
print invoice-engine::web/print-invoice
printed invoice-engine::web/printed-invoice
invoice-engine::view-invoice
send invoice-engine::web/send-invoice-by-email

“‘

Less fancy, but useful too, you can also use ‘(describe easy-routes:*routes-mapper*)‘ to visualize the tree of routes.

## Augmented error pages and logs

You can get augmented error pages and logs with request, session and route information, adding ‘easy-routes+errors‘ as dependency, and subclassing from ‘easy-routes-errors-acceptor‘, like:

“‘lisp
(defclass my-acceptor (easy-routes:easy-routes-acceptor easy-routes::easy-routes-errors-acceptor)
())
“‘
This is implemented with [hunchentoots-errors](https://github.com/mmontone/hunchentoot-errors) library.

## Djula integration

‘easy-routes+djula‘ system implements support for generating easy-routes urls using route names and arguments in Djula templates (calls ‘genurl‘ function).

Djula template syntax:
“‘
{% genurl route-name &rest args %}
“‘

Example:
“‘
{% genurl my-route :id 22 :foo template-var.key %}
“‘

## Reference ##

## Functions
### @html

“‘lisp
(next)
“‘

HTML decoration. Sets reply content type to text/html

### find-route

“‘lisp
(name)
“‘

Find a route by name (symbol)

### genurl

“‘lisp
(route-symbol &rest args &key &allow-other-keys)
“‘

Generate a relative url from a route name and arguments

### genurl\*

“‘lisp
(route-symbol &rest args &key &allow-other-keys)
“‘

Generate an absolute url from a route name and arguments

### redirect

“‘lisp
(route-symbol &rest args)
“‘
Redirect to a route url. Pass the route name and the parameters.

## Macros
### defroute

“‘lisp
(name template-and-options params &body body)
“‘

Route definition syntax

## Classes

### easy-routes-acceptor
This acceptor tries to match and handle easy-routes first, but fallbacks to easy-routes dispatcher if there’s no matching

### routes-acceptor
This acceptors handles routes and only routes. If no route is matched then an HTTP NOT FOUND error is returned.
If you want to use Hunchentoot easy-handlers dispatch as a fallback, use EASY-ROUTES-ACCEPTOR

Dependencies
  • hunchentoot (system).
  • routes (system).
Source

easy-routes.asd.

Child Components

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp   [Contents][Index]

3.1.1 easy-routes/easy-routes.asd

Source

easy-routes.asd.

Parent Component

easy-routes (system).

ASDF Systems

easy-routes.


3.1.2 easy-routes/package.lisp

Source

easy-routes.asd.

Parent Component

easy-routes (system).

Packages

easy-routes.


3.1.3 easy-routes/util.lisp

Dependency

package.lisp (file).

Source

easy-routes.asd.

Parent Component

easy-routes (system).

Internals

3.1.4 easy-routes/easy-routes.lisp

Dependency

util.lisp (file).

Source

easy-routes.asd.

Parent Component

easy-routes (system).

Public Interface
Internals

3.1.5 easy-routes/routes-map-printer.lisp

Dependency

easy-routes.lisp (file).

Source

easy-routes.asd.

Parent Component

easy-routes (system).

Internals

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 easy-routes

Source

package.lisp.

Use List

common-lisp.

Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Public Interface


Next: , Previous: , Up: Public Interface   [Contents][Index]

5.1.1 Special variables

Special Variable: *routes-mapper*

This is the cl-routes map of routes.
cl-routes implements special SWANK inspect code and prints routes mappers as a tree. Just inspect *routes-mapper* from the Lisp listener to see.

Package

easy-routes.

Source

easy-routes.lisp.


5.1.2 Macros

Macro: defroute (name template-and-options params &body body)

Macro for defining a route.

Syntax:

(defroute <name> (<path> &rest <route-options>) <route-params>
&body body)

with:

* path: A string with an url path that can contain arguments prefixed with a colon.
Like "/foo/:x/:y", where :x and :y are bound into x and y variables in the context of the route body.
* route-options: possible options are
* :method - The HTTP method to dispatch, as a keyword. Default is :get.
* :decorators - The decorators to attach.
* :acceptor-name - The name of the acceptor the route should be added to (optional).
* route-params: a list of params to be extracted from the url or HTTP request body (POST).
Has this form: (params &get get-params &post post-params &path path-params), with the &get, &post and &path params sections being optional, and where params are grabbed via HUNCHENTOOT:PARAMETER function, get-params via HUNCHENTOOT:GET-PARAMETER function, and post-params via HUNCHENTOOT:POST-PARAMETER function. path-params specifies the type of params in the url path.

For example:

(easy-routes:defroute name ("/foo/:x") (y &get z)
(format nil "x: ~a y: ~a z: ~a x y z))

Also, params can have Hunchentoot easy-handler style options, described here: http://weitz.de/hunchentoot/#define-easy-handler

(var &key real-name parameter-type init-form request-type)

For example:

(easy-routes:defroute foo "/foo/:x"
((y :real-name "Y" :init-form 22 :parameter-type ’integer))
(format nil "~A - ~A" x y))

You can also specify the type of path parameters after &path. For example, say you want to sum a path argument to a query argument. You can specify their type as ’INTEGER and calculate their sum without parsing:

(easy-routes:defroute foo "/foo/:x"
((y :init-form 10 :parameter-type ’integer)
&path (x ’integer))
(format nil "~A" (+ x y)))

Package

easy-routes.

Source

easy-routes.lisp.


5.1.3 Ordinary functions

Function: @check (predicate http-error next)

Decorator that checks if PREDICATE evaluation is true.
PREDICATE is a funcallable object.
If the check succeeds, then the NEXT middleware is called.
If the check fails, then the request is aborted with HTTP status HTTP-ERROR.

Example usage:

(defroute my-route ("/my-route" :method :get
:decorators ((@check my-permissions-checking-function hunchentoot:+http-forbidden+))) ...
)

Package

easy-routes.

Source

easy-routes.lisp.

Function: @check-permission (predicate next)

Decorator that aborts the current request with a HTTP permission denied error if the evaluation of PREDICATE is false. PREDICATE is a funcallable object.

Package

easy-routes.

Source

easy-routes.lisp.

Function: @html (next)

HTML decoration. Sets reply content type to text/html

Package

easy-routes.

Source

easy-routes.lisp.

Function: @json (next)

JSON decoration. Sets reply content type to application/json

Package

easy-routes.

Source

easy-routes.lisp.

Function: find-route (name &key acceptor-name)

Find a route by name (symbol)

Package

easy-routes.

Source

easy-routes.lisp.

Function: genurl (route-symbol &rest args &key &allow-other-keys)

Generate a relative url from a route name and arguments

Package

easy-routes.

Source

easy-routes.lisp.

Function: genurl* (route-symbol &rest args &key &allow-other-keys)

Generate an absolute url from a route name and arguments.

Looks at HUNCHENTOOT:*REQUEST* and HUNCHENTOOT:*ACCEPTOR* to infer host and uri scheme. If HUNCHENTOOT:*REQUEST* and HUNCHENTOOT:*ACCEPTOR* are not bound, then "http" and "localhost" are used as uri scheme and host.

Package

easy-routes.

Source

easy-routes.lisp.

Function: http-error (http-error &optional result)

Abort current handler and signal HTTP error HTTP-ERROR.

HTTP-ERROR should be an HTTP status code (integer).

Package

easy-routes.

Source

easy-routes.lisp.

Function: not-found-error (&optional result)

Aborts current handler and returns with an HTTP not found error.

Package

easy-routes.

Source

easy-routes.lisp.

Function: or-http-error (value http-error &optional result)

Utility function for signaling HTTP-ERROR if VALUE is null.

HTTP-ERROR should be an HTTP status code (integer).

Package

easy-routes.

Source

easy-routes.lisp.

Function: or-not-found (value &optional result)

Utility function for signaling an HUNCHENTOOT:+HTTP-NOT-FOUND+ error if VALUE is null.

Use in your routes like:

(let ((my-object (or-not-found (find-my-object id))))
...)

where id is a route parameter.

The route retuns an HTTP not found error if object with that id could not be found.

Package

easy-routes.

Source

easy-routes.lisp.

Function: permission-denied-error (&optional result)

Aborts current handler and returns with an HTTP forbidden error.

Package

easy-routes.

Source

easy-routes.lisp.

Function: redirect (route-symbol &rest args)

Redirect to a route with name ROUTE-SYMBOL. ARGS is a property list with route parameters.

Package

easy-routes.

Source

easy-routes.lisp.


5.1.4 Standalone methods

Method: acceptor-dispatch-request ((acceptor easy-routes-acceptor) request)
Package

hunchentoot.

Source

easy-routes.lisp.

Method: acceptor-dispatch-request ((acceptor routes-acceptor) request)
Package

hunchentoot.

Source

easy-routes.lisp.

Method: print-object ((route route) stream)
Source

easy-routes.lisp.

Method: route-check-conditions ((route route) bindings)
Package

routes.

Source

easy-routes.lisp.

Method: route-name ((route route))
Package

routes.

Source

easy-routes.lisp.


5.1.5 Classes

Class: easy-routes-acceptor

This acceptor tries to match and handle easy-routes first, but fallbacks to easy-routes dispatcher if there’s no matching

Package

easy-routes.

Source

easy-routes.lisp.

Direct superclasses

easy-acceptor.

Direct subclasses

easy-routes-ssl-acceptor.

Direct methods

acceptor-dispatch-request.

Class: easy-routes-ssl-acceptor

As for EASY-ROUTES-ACCEPTOR, but works with the hunchentoot EASY-SSL-ACCEPTOR instead.

Package

easy-routes.

Source

easy-routes.lisp.

Direct superclasses
Class: route
Package

easy-routes.

Source

easy-routes.lisp.

Direct superclasses

route.

Direct methods
Direct slots
Slot: symbol
Package

common-lisp.

Type

symbol

Initargs

:symbol

Readers

route-symbol.

Writers

This slot is read-only.

Slot: variables
Initargs

:variables

Readers

variables.

Writers

This slot is read-only.

Slot: required-method
Type

(satisfies easy-routes::valid-route-method-p)

Initargs

:required-method

Readers

required-method.

Writers

This slot is read-only.

Slot: decorators
Type

list

Initargs

:decorators

Readers

route-decorators.

Writers

This slot is read-only.

Class: routes-acceptor

This acceptors handles routes and only routes. If no route is matched then an HTTP NOT FOUND error is returned. If you want to use Hunchentoot easy-handlers dispatch as a fallback, use EASY-ROUTES-ACCEPTOR

Package

easy-routes.

Source

easy-routes.lisp.

Direct superclasses

acceptor.

Direct methods

acceptor-dispatch-request.


5.2 Internals


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.1 Special variables

Special Variable: *acceptors-routes-and-mappers*

Routes and route mappers for individual acceptors

Package

easy-routes.

Source

easy-routes.lisp.

Special Variable: *current-indention*
Package

easy-routes.

Source

routes-map-printer.lisp.

Special Variable: *indention*
Package

easy-routes.

Source

routes-map-printer.lisp.

Special Variable: *route*

The current route

Package

easy-routes.

Source

easy-routes.lisp.

Special Variable: *routes*
Package

easy-routes.

Source

easy-routes.lisp.


5.2.2 Macros

Macro: assoc-bind (lambda-list alist &body body)
Package

easy-routes.

Source

util.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.3 Ordinary functions

Function: acceptor-routes (acceptor-name)
Package

easy-routes.

Source

easy-routes.lisp.

Function: acceptor-routes-mapper (acceptor-name)
Package

easy-routes.

Source

easy-routes.lisp.

Function: apply-format-aux (format args)
Package

easy-routes.

Source

easy-routes.lisp.

Function: call-decorator (decorator next)
Package

easy-routes.

Source

easy-routes.lisp.

Function: call-with-decorators (decorators function)
Package

easy-routes.

Source

easy-routes.lisp.

Function: connect-routes (acceptor-name)
Package

easy-routes.

Source

easy-routes.lisp.

Function: ensure-acceptor-routes-and-mapper (acceptor-name)
Package

easy-routes.

Source

easy-routes.lisp.

Function: lambda-list-split (template lam-list)
Package

easy-routes.

Source

util.lisp.

Function: parse-host-and-port (host-header)

Parse host and port from a Host HTTP reader.

Package

easy-routes.

Source

easy-routes.lisp.

Function: route-symbol-template (route-symbol)
Package

easy-routes.

Source

easy-routes.lisp.

Function: valid-route-method-p (method-spec)
Package

easy-routes.

Source

easy-routes.lisp.


Next: , Previous: , Up: Internals   [Contents][Index]

5.2.4 Generic functions

Generic Function: make-route-url (tmpl args)
Package

easy-routes.

Methods
Method: make-route-url ((route route) args)
Source

easy-routes.lisp.

Method: make-route-url ((route symbol) args)
Source

easy-routes.lisp.

Method: make-route-url ((tmpl list) args)
Source

easy-routes.lisp.

Generic Function: print-route (route stream)
Package

easy-routes.

Source

routes-map-printer.lisp.

Methods
Method: print-route ((route concat-template) stream)
Method: print-route ((route or-template) stream)
Method: print-route ((route cons) stream)
Method: print-route ((route wildcard-template) stream)
Method: print-route ((route variable-template) stream)
Method: print-route ((route route) stream)
Method: print-route (route stream)
Generic Function: process-route (acceptor route bindings)
Package

easy-routes.

Source

easy-routes.lisp.

Methods
Method: process-route ((acceptor acceptor) (route route) bindings)
Generic Reader: required-method (object)
Package

easy-routes.

Methods
Reader Method: required-method ((route route))

automatically generated reader method

Source

easy-routes.lisp.

Target Slot

required-method.

Generic Reader: route-decorators (object)
Package

easy-routes.

Methods
Reader Method: route-decorators ((route route))

automatically generated reader method

Source

easy-routes.lisp.

Target Slot

decorators.

Generic Reader: route-symbol (object)
Package

easy-routes.

Methods
Reader Method: route-symbol ((route route))

automatically generated reader method

Source

easy-routes.lisp.

Target Slot

symbol.

Generic Reader: variables (object)
Package

easy-routes.

Methods
Reader Method: variables ((route route))

automatically generated reader method

Source

easy-routes.lisp.

Target Slot

variables.


Previous: , Up: Internals   [Contents][Index]

5.2.5 Types

Type: http-method ()
Package

easy-routes.

Source

easy-routes.lisp.


Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts


Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   @  
A   C   D   E   F   G   H   L   M   N   O   P   R   V  
Index Entry  Section

@
@check: Public ordinary functions
@check-permission: Public ordinary functions
@html: Public ordinary functions
@json: Public ordinary functions

A
acceptor-dispatch-request: Public standalone methods
acceptor-dispatch-request: Public standalone methods
acceptor-routes: Private ordinary functions
acceptor-routes-mapper: Private ordinary functions
apply-format-aux: Private ordinary functions
assoc-bind: Private macros

C
call-decorator: Private ordinary functions
call-with-decorators: Private ordinary functions
connect-routes: Private ordinary functions

D
defroute: Public macros

E
ensure-acceptor-routes-and-mapper: Private ordinary functions

F
find-route: Public ordinary functions
Function, @check: Public ordinary functions
Function, @check-permission: Public ordinary functions
Function, @html: Public ordinary functions
Function, @json: Public ordinary functions
Function, acceptor-routes: Private ordinary functions
Function, acceptor-routes-mapper: Private ordinary functions
Function, apply-format-aux: Private ordinary functions
Function, call-decorator: Private ordinary functions
Function, call-with-decorators: Private ordinary functions
Function, connect-routes: Private ordinary functions
Function, ensure-acceptor-routes-and-mapper: Private ordinary functions
Function, find-route: Public ordinary functions
Function, genurl: Public ordinary functions
Function, genurl*: Public ordinary functions
Function, http-error: Public ordinary functions
Function, lambda-list-split: Private ordinary functions
Function, not-found-error: Public ordinary functions
Function, or-http-error: Public ordinary functions
Function, or-not-found: Public ordinary functions
Function, parse-host-and-port: Private ordinary functions
Function, permission-denied-error: Public ordinary functions
Function, redirect: Public ordinary functions
Function, route-symbol-template: Private ordinary functions
Function, valid-route-method-p: Private ordinary functions

G
Generic Function, make-route-url: Private generic functions
Generic Function, print-route: Private generic functions
Generic Function, process-route: Private generic functions
Generic Function, required-method: Private generic functions
Generic Function, route-decorators: Private generic functions
Generic Function, route-symbol: Private generic functions
Generic Function, variables: Private generic functions
genurl: Public ordinary functions
genurl*: Public ordinary functions

H
http-error: Public ordinary functions

L
lambda-list-split: Private ordinary functions

M
Macro, assoc-bind: Private macros
Macro, defroute: Public macros
make-route-url: Private generic functions
make-route-url: Private generic functions
make-route-url: Private generic functions
make-route-url: Private generic functions
Method, acceptor-dispatch-request: Public standalone methods
Method, acceptor-dispatch-request: Public standalone methods
Method, make-route-url: Private generic functions
Method, make-route-url: Private generic functions
Method, make-route-url: Private generic functions
Method, print-object: Public standalone methods
Method, print-route: Private generic functions
Method, print-route: Private generic functions
Method, print-route: Private generic functions
Method, print-route: Private generic functions
Method, print-route: Private generic functions
Method, print-route: Private generic functions
Method, print-route: Private generic functions
Method, process-route: Private generic functions
Method, required-method: Private generic functions
Method, route-check-conditions: Public standalone methods
Method, route-decorators: Private generic functions
Method, route-name: Public standalone methods
Method, route-symbol: Private generic functions
Method, variables: Private generic functions

N
not-found-error: Public ordinary functions

O
or-http-error: Public ordinary functions
or-not-found: Public ordinary functions

P
parse-host-and-port: Private ordinary functions
permission-denied-error: Public ordinary functions
print-object: Public standalone methods
print-route: Private generic functions
print-route: Private generic functions
print-route: Private generic functions
print-route: Private generic functions
print-route: Private generic functions
print-route: Private generic functions
print-route: Private generic functions
print-route: Private generic functions
process-route: Private generic functions
process-route: Private generic functions

R
redirect: Public ordinary functions
required-method: Private generic functions
required-method: Private generic functions
route-check-conditions: Public standalone methods
route-decorators: Private generic functions
route-decorators: Private generic functions
route-name: Public standalone methods
route-symbol: Private generic functions
route-symbol: Private generic functions
route-symbol-template: Private ordinary functions

V
valid-route-method-p: Private ordinary functions
variables: Private generic functions
variables: Private generic functions

Jump to:   @  
A   C   D   E   F   G   H   L   M   N   O   P   R   V