An open API service indexing awesome lists of open source software.

https://github.com/40ants/routes

Framework agnostic URL routing library.
https://github.com/40ants/routes

common-lisp routing web

Last synced: 9 days ago
JSON representation

Framework agnostic URL routing library.

Awesome Lists containing this project

README

          

# 40ants-routes - Framework agnostic URL routing library

## 40ANTS-ROUTES ASDF System Details

* Description: Framework agnostic `URL` routing library.
* Licence: Unlicense
* Author: Alexander Artemenko
* Homepage: [https://40ants.com/routes][7261]
* Bug tracker: [https://github.com/40ants/routes/issues][54bf]
* Source control: [GIT][6959]
* Depends on: [alexandria][8236], [cl-ppcre][49b9], [serapeum][c41d], [split-sequence][3dcd], [str][ef7f]

## Overview

40ants-routes is a framework-agnostic `URL` routing library for Common Lisp, inspired by Django's `URL` routing system. It provides a clean and flexible way to define `URL` routes, generate `URL`s, and handle `URL` parameters.

## Features

* Defining routes with namespaces.
* Including routes from libraries into applications.
* Matching `URL` while extracting parameters from it.
* Generating `URL`s based on route names.
* Generating breadcrumbs.

## Installation

```lisp
(ql:quickload :40ants-routes)
```

## Usage Examples

### Defining Routes

Routes can be defined using the [`40ants-routes/defroutes:defroutes`][3455] macro.

Inside it's body, use [`40ants-routes/defroutes:get`][f902], [`40ants-routes/defroutes:post`][a861], macro
to define final routes in the collection.

```

(uiop:define-package #:test-routes
(:use #:cl)
(:shadowing-import-from #:40ants-routes/defroutes
#:defroutes
#:include
#:get
#:post)
(:import-from #:40ants-routes/route-url
#:route-url)
(:import-from #:40ants-routes/handler
#:call-handler)
(:import-from #:40ants-routes/with-url
#:with-partially-matched-url
#:with-url))
(in-package #:test-routes)

(defroutes (*blog-routes* :namespace "blog")
(get ("/" :name "index")
(format t "Handler for blog index was called."))
(get ("/" :name "post")
(format t "Handler for blog post ~S was called."
slug)))
```
Routes, defined by this [`40ants-routes/defroutes:defroutes`][3455] are stored in `*blog-routes*` variable
and can be used either to [`40ants-routes/defroutes:include`][2897] these routes into the route hierarchy,
or to search a route, matched to the `URL`. See section [`Matching the URL`][af0d].

Here's an example demonstrating how to use an integer `URL` parameter:

```lisp
(defroutes (*article-routes* :namespace "articles")
(get ("/" :name "index")
(format t "Handler for articles index was called."))
(get ("/" :name "article")
(format t "Handler for article with ID ~D was called."
id)))
```
In this example, the route will match `URL`s like `/123` and the argument `ID` will be parsed as an integer.

You can also capture the rest of the `URL` as a parameter using the `.*` regex pattern:

```lisp
(defroutes (*file-routes* :namespace "files")
(get ("/" :name "index")
(format t "Handler for files index was called."))
(get ("/<.*:path>" :name "file")
(format t "Handler for file at path ~S was called."
path)))
```
This will match `URL`s like `/documents/reports/annual/2023.pdf` and capture the entire path
`documents/reports/annual/2023.pdf` as the `PATH` argument.

### Including Routes

Routes from libraries can be included in application routes using
[`40ants-routes/defroutes:include`][2897] function.

This way they can form a hyerarchy:

```lisp
(defroutes (*app-routes* :namespace "app")
(get ("/" :name "index")
(format t "Handler for application's index page."))
(include *blog-routes*
:path "/blog/"))
```
In it's turn, `*blog-routes*` might also include other routes itself.

This allows to build a composable web-applications and libraries. For example,
some library might build routes to show the list of objects, show details about an object,
edit it and delete. Then such routes can be included into a more complex application.

### Matching the URL

Imagine, user have opened the `URL` with a path like this `/blog/some-post`.

Then in your web-application you might setup the context in which this route
processing should happen. Use [`40ants-routes/with-url:with-url`][1c5e] or [`40ants-routes/with-url:with-partially-matched-url`][1a23]
macros to setup the context. Inside the context you can use [`call-handler`][e530] function to call
a body of the route, matched to the `URL`:

```lisp

TEST-ROUTES> (with-url (*app-routes* "/blog/some-post")
(call-handler))
Handler for blog post "some-post" was called.

TEST-ROUTES> (with-url (*app-routes* "/blog/")
(call-handler))
Handler for blog index was called.

TEST-ROUTES> (with-url (*app-routes* "/")
(call-handler))
Handler for application's index page.
```
[`40ants-routes/with-url:with-url`][1c5e] will signal [`40ants-routes/errors:no-route-for-url-error`][2977]
error if there is no route matching the whole `URL`, but [`40ants-routes/with-url:with-partially-matched-url`][1a23] will
try to do the best it can.

So, inside the [`40ants-routes/with-url:with-url`][1c5e] body you can use [`call-handler`][e530]
always, while inside the [`40ants-routes/with-url:with-partially-matched-url`][1a23] macro handler should be called only if
[`40ants-routes/route:current-route-p`][087c] function returns T.

### Generating URLs

Another feature of `40ants-routes` is `URL` generation.
`URL`s can be generated using the [`40ants-routes/route-url:route-url`][fe8a] function. Like
[`call-handler`][e530], it should be called when `URL` context is available.

In our application routes tree there are two `index` routes, but we can get paths to both of them
using namespaces. Route's namespace is defined as a list of names from the root route, given
to the [`with-url`][1c5e] macro up to the matched route. Each [`defroutes`][3455] form or a call to [`include`][2897] form
create an object having the name. These names are added to the current route's namespace.

Imagine we are on the blog-post page and we want to get path to all blog posts. Easiest way
to do this, is to call [`route-url`][fe8a] function with only route name:

```lisp
TEST-ROUTES> (with-url (*app-routes* "/blog/some-post")
(route-url "index"))
"/blog/"
```
But this will not work if the user is on the root page:

```lisp
TEST-ROUTES> (with-url (*app-routes* "/")
(route-url "index"))
"/"
```
You might want to make `URL` resolution more stable, especially if these `URL`s are used in some common
page parts such as header or footer. In this case, help `URL` resolver by giving it a namespace:

```lisp
TEST-ROUTES> (with-url (*app-routes* "/")
(route-url "index"
:namespace '("app" "blog")))
"/blog/"
```
Note, when you are building a reusable component which creates it's own `40ants-routes/routes:routes` ([`1`][77f9] [`2`][cce3])
object, you should not use these absolute namespaces, because you don't know beforehand which namespace
will be used by user when including the component's routes.

Let's update our blog component routes and add one to edit the blog post:

```lisp
TEST-ROUTES> (defroutes (*blog-routes* :namespace "blog")
(get ("/" :name "index")
(format t "Handler for blog index was called."))
(get ("/" :name "post")
(format t "Handler for blog post ~S was called.~
To edit post go to ~S."
slug
(route-url "edit-post"
:slug slug)))
(get ("//edit" :name "edit-post")
(format t "Handler for blog post ~S edit form was called."
slug)))
#<40ANTS-ROUTES/ROUTES:ROUTES "blog" 3 subroutes>
```
Note, how we did use [`route-url`][fe8a] inside the `/` handler to get
path to the post edit page.

Now, let's try to call this handler when this blog's routes are included
into the application routes:

```lisp
TEST-ROUTES> (with-url (*app-routes* "/blog/some-post")
(call-handler))
Handler for blog post "some-post" was called.To edit post go to "/blog/some-post/edit".
```
See, it did return `/blog/some-post/edit` path to the edit page and there wasn't need to specify
a namespace at all!

### Generating Breadcrumbs

Breadcrumbs can be generated using the [`40ants-routes/breadcrumbs:get-breadcrumbs`][bd21] function. This function returns a list of [`40ants-routes/breadcrumbs:breadcrumb`][e419] objects that represent the path from the root to the current page.

Each [`40ants-routes/breadcrumbs:breadcrumb`][e419] object has the following properties:
- The `URL` path to the breadcrumb (accessible via [`40ants-routes/breadcrumbs:breadcrumb-path`][3f6e])
- The display title for the breadcrumb (accessible via [`40ants-routes/breadcrumbs:breadcrumb-title`][b28f])
- The route object associated with the breadcrumb (accessible via [`40ants-routes/breadcrumbs:breadcrumb-route`][920e])

To use breadcrumbs, you need to define routes with titles:

```lisp

(defroutes (*admin-users-routes* :namespace "users")
(post ("/" :name "users"
:title "Users")
(format nil "Users list"))
(get ("/"
:name "user"
:title "User Profile")
(format nil "User profile: ~A" username)))

(defroutes (*admin-routes* :namespace "admin")
(get ("/" :name "admin-index" :title "Admin")
(format nil "Admin index"))
(include *admin-users-routes*
:path "/users/"))

(defroutes (*app-routes* :namespace "app")
(get ("/" :name "index" :title "Home")
(format nil "App index"))
(include *admin-routes*
:path "/admin/"))
```
Then, you can generate breadcrumbs for a specific `URL`:

```lisp

TEST-ROUTES> (with-url (*app-routes* "/admin/users/john")
(let ((crumbs (40ants-routes/breadcrumbs:get-breadcrumbs)))
;; This way you can get all paths or titles:
(values
(mapcar #'40ants-routes/breadcrumbs:breadcrumb-path crumbs)
(mapcar #'40ants-routes/breadcrumbs:breadcrumb-title crumbs))))
("/" "/admin/" "/admin/users/" "/admin/users/john")
("Home" "Admin" "Users" "User Profile")
```
or to generate an `HTML` code like this:

```lisp

TEST-ROUTES> (with-url (*app-routes* "/admin/users/john")
(let ((crumbs (40ants-routes/breadcrumbs:get-breadcrumbs)))
(format t "~%")
(format t "

    ~%")
    (loop for crumb in crumbs
    for last-p = (eq crumb (car (last crumbs)))
    do (format t "
  1. ~%"
    last-p last-p)
    (if last-p
    (format t " ~A~%" (40ants-routes/breadcrumbs:breadcrumb-title crumb))
    (format t " ~A~%"
    (40ants-routes/breadcrumbs:breadcrumb-path crumb)
    (40ants-routes/breadcrumbs:breadcrumb-title crumb)))
    (format t "
  2. ~%"))
    (format t "
~%")
(format t "~%")))

```
For more advanced usage, you can also use functions as route titles to generate dynamic titles based on `URL` parameters. This is demonstrated in the test file:

First, you need to define a function which will accept an arguments extracted from `URL`:

```lisp
(defun get-user-name (&key username &allow-other-keys)
"A function for retrieving user display names based on username parameter"
(cond
((string= username "john")
"John Smith")
((string= username "jane")
"Jane Doe")
(t
(format nil "User: ~A" username))))
```
Then redefine routes, to use this function as `TITLE` argument of the route:

```
(defroutes (*admin-users-routes* :namespace "users")
(post ("/" :name "users" :title "Users")
(format nil "Users list"))
(get ("/"
:name "user"
;; Example of using a function for retrieving
;; route title dynamically at runtime:
:title #'get-user-name)
(format nil "User profile: ~A" username)))
```
And now you will get a real user's name as the last breadcrumb title:

```lisp

TEST-ROUTES> (with-url (*app-routes* "/admin/users/john")
(let ((crumbs (40ants-routes/breadcrumbs:get-breadcrumbs)))
(values
(mapcar #'40ants-routes/breadcrumbs:breadcrumb-path crumbs)
(mapcar #'40ants-routes/breadcrumbs:breadcrumb-title crumbs))))
("/" "/admin/" "/admin/users/" "/admin/users/john")
("Home" "Admin" "Users" "John Smith")
```
This makes it easy to create meaningful breadcrumb navigation that adapts to the content being displayed.

## API Reference

### 40ANTS-ROUTES/BREADCRUMBS

#### [package](80be) `40ants-routes/breadcrumbs`

#### Classes

##### BREADCRUMB

###### [class](6b1c) `40ants-routes/breadcrumbs:breadcrumb` ()

**Readers**

###### [reader](895a) `40ants-routes/breadcrumbs:breadcrumb-path` (breadcrumb) (:path)

###### [reader](27fe) `40ants-routes/breadcrumbs:breadcrumb-route` (breadcrumb) (:route)

###### [reader](5dcf) `40ants-routes/breadcrumbs:breadcrumb-title` (breadcrumb) (:title)

#### Functions

##### [function](53c4) `40ants-routes/breadcrumbs:get-breadcrumbs`

Generate breadcrumbs list for the current `URL` set by [`40ants-routes/with-url:with-url`][1c5e] macro.

##### [function](dec1) `40ants-routes/breadcrumbs:make-breadcrumb` title

Creates a breadcrumb item.

### 40ANTS-ROUTES/DEFROUTES

#### [package](31be) `40ants-routes/defroutes`

#### Functions

##### [function](c5b9) `40ants-routes/defroutes:include` routes &key (path "/")

#### Macros

##### [macro](f7eb) `40ants-routes/defroutes:defroutes` (var-name &key namespace (routes-class 'routes)) &body route-definitions

Define a variable holding collection of routes and binds it to a variable `VAR-NAME`.

This macro acts like a `DEFVAR` - if there is already an `40ants-routes/routes:routes` ([`1`][77f9] [`2`][cce3])
object bound to the variable, then it is not replaced, but updated inplace.
This allows to change routes on the fly even if they were included into some routes
hierarchy.

You can use `ROUTES-CLASS` argument to supply you own class, inherited from `routes` ([`1`][77f9] [`2`][cce3]).
This way it might be possible to special processing for these routes, for example,
inject some special code for representing this routes in the "breadcrumbs".

Use [`get`][f902], [`post`][a861], [`put`][c587], `DELETE` macros in `ROUTE-DEFINITIONS` forms.

See more examples how to define routes in the
[`Defining Routes`][d39a] section.

##### [macro](8a76) `40ants-routes/defroutes:get` (path &key name title (route-class 'route)) &body handler-body

##### [macro](bb9a) `40ants-routes/defroutes:post` (path &key name title (route-class 'route)) &body handler-body

##### [macro](aba5) `40ants-routes/defroutes:put` (path &key name title (route-class 'route)) &body handler-body

### 40ANTS-ROUTES/ERRORS

#### [package](2356) `40ants-routes/errors`

#### Classes

##### ARGUMENT-MISSING-ERROR

###### [condition](4f03) `40ants-routes/errors:argument-missing-error` (error)

**Readers**

###### [reader](4f03) `40ants-routes/errors:argument-missing-error-parameter` (argument-missing-error) (:missing-parameter)

###### [reader](4f03) `40ants-routes/errors:argument-missing-error-route-name` (argument-missing-error) (:route-name)

##### NAMESPACE-DUPLICATION-ERROR

###### [condition](ac63) `40ants-routes/errors:namespace-duplication-error` (error)

**Readers**

###### [reader](ac63) `40ants-routes/errors:existing-namespace` (namespace-duplication-error) (:namespace)

###### [reader](ac63) `40ants-routes/errors:existing-route` (namespace-duplication-error) (:existing-route)

###### [reader](ac63) `40ants-routes/errors:new-route` (namespace-duplication-error) (:new-route)

##### NO-COMMON-ELEMENTS-ERROR

###### [condition](0a57) `40ants-routes/errors:no-common-elements-error` (error)

**Readers**

###### [reader](0a57) `40ants-routes/errors:full-namespace` (no-common-elements-error) (:full-namespace)

###### [reader](0a57) `40ants-routes/errors:relative-namespace` (no-common-elements-error) (:relative-namespace)

##### NO-ROUTE-FOR-URL-ERROR

###### [condition](1b13) `40ants-routes/errors:no-route-for-url-error` (error)

**Readers**

###### [reader](1b13) `40ants-routes/errors:error-routes-path` (no-route-for-url-error) (:routes-path)

###### [reader](1b13) `40ants-routes/errors:error-url` (no-route-for-url-error) (:url)

##### PATH-DUPLICATION-ERROR

###### [condition](4370) `40ants-routes/errors:path-duplication-error` (error)

**Readers**

###### [reader](4370) `40ants-routes/errors:existing-path` (path-duplication-error) (:path)

###### [reader](4370) `40ants-routes/errors:existing-route` (path-duplication-error) (:existing-route)

###### [reader](4370) `40ants-routes/errors:new-route` (path-duplication-error) (:new-route)

##### URL-RESOLUTION-ERROR

###### [condition](8ef4) `40ants-routes/errors:url-resolution-error` (error)

**Readers**

###### [reader](8ef4) `40ants-routes/errors:namespace` (url-resolution-error) (:namespace)

###### [reader](8ef4) `40ants-routes/errors:route-name` (url-resolution-error) (:route-name)

### 40ANTS-ROUTES/FIND-ROUTE

#### [package](b185) `40ants-routes/find-route`

#### Functions

##### [function](3d53) `40ants-routes/find-route:find-route` name &key namespace on-match

Find a route by name in the given namespace hierarchy.

If route was found, then returns it.

Additionally, it will call `ON-MATCH` callable argument
with each route node along path to the leaf route.

### 40ANTS-ROUTES/GENERICS

#### [package](7799) `40ants-routes/generics`

#### Generics

##### [generic-function](7fb4) `40ants-routes/generics:add-route` routes route-or-routes-to-add &key override

Add a route or included-routes object to the routes collection at runtime.
If a route with the same path or namespace already exists, an error will be signaled
unless override is set to true.

##### [generic-function](1f44) `40ants-routes/generics:format-url` obj stream args

Should write a piece of `URL` to the `STREAM` substituting arguments from plist `ARGS`.

When called, it should write a piece of `URL` without starting backslash.

##### [generic-function](50cd) `40ants-routes/generics:get-route-breadcrumbs` node

Returns a list of breadcrumbs associated with given routes node.

`NODE` argument could have [`40ants-routes/route:route`][377c] class, [`40ants-routes/routes:routes`][cce3] class or an object of other
class bound to some object of [`40ants-routes/route:route`][377c] class.

For objects of class [`40ants-routes/routes:routes`][cce3] usually the method return breadcrumbs of the
route having the `/` path.

Method can return from zero to N objects of [`40ants-routes/breadcrumbs:breadcrumb`][e419] class.
A returning of multiple breadcrumbs can be useful if route matches to some filename in a nested directory
and you want to give an ability to navigate into intermediate directories.

##### [generic-function](5327) `40ants-routes/generics:has-namespace-p` routes

Returns T of node can respond to [`node-namespace`][db92] generic-function call.

##### [generic-function](640c) `40ants-routes/generics:match-url` obj url &key on-match

Checks for complete match of the object to `URL`.

Should return an `OBJ` if it fully matches to a given url.
May return a sub-object if `OBJ` matches to a prefix
and sub-object matches the rest of `URL`.

If match was found, the second returned value
should be a alist with matched parameters.

If `ON-MATCH` argument is given, then in any case
of match, full or prefix, calls `ON-MATCH`
function with `OBJ` as a single argument.

##### [generic-function](222b) `40ants-routes/generics:node-namespace` routes

Returns a string name of node's namepace. Works only for objects for which [`has-namespace-p`][3eec] returns true.

##### [generic-function](b135) `40ants-routes/generics:partial-match-url` obj url

Tests of obj matches to the a prefix of `URL`.

If match was found, should return two
values: the object which matches and position of
the character after the matched prefix.

If `OBJ` is a compound element, then
a sub-element can be returned in case of match.

##### [generic-function](45ef) `40ants-routes/generics:url-path` obj

Returns the [`40ants-routes/url-pattern:url-pattern`][a13f] associated with the object.

### 40ANTS-ROUTES/HANDLER

#### [package](01b4) `40ants-routes/handler`

#### Functions

##### [function](4c47) `40ants-routes/handler:call-handler`

Calls a handler of current route.

Should be called only during [`40ants-routes/with-url:with-url`][1c5e] macro body execution.

### 40ANTS-ROUTES/INCLUDED-ROUTES

#### [package](31c6) `40ants-routes/included-routes`

#### Classes

##### INCLUDED-ROUTES

###### [class](3ce2) `40ants-routes/included-routes:included-routes` ()

**Readers**

###### [reader](b9bd) `40ants-routes/included-routes:original-routes` (included-routes) (:original-collection)

The original collection that was included

###### [reader](43c2) `40ants-routes/generics:url-path` (included-routes) (:path)

Path to add to all routes in the collection

#### Functions

##### [function](d0d5) `40ants-routes/included-routes:included-routes-p` obj

### 40ANTS-ROUTES/MATCHED-ROUTE

#### [package](4e55) `40ants-routes/matched-route`

#### Classes

##### MATCHED-ROUTE

###### [class](21dc) `40ants-routes/matched-route:matched-route` ()

**Readers**

###### [reader](40df) `40ants-routes/matched-route:matched-route-parameters` (matched-route) (:parameters = nil)

Parameters extracted from the `URL` pattern as alist where keys are parameter names and values - parameter types.

###### [reader](acf8) `40ants-routes/matched-route:original-route` (matched-route) (:original-route)

The original [`route`][377c] object which has been matched.

#### Functions

##### [function](5224) `40ants-routes/matched-route:matched-route-p` obj

### 40ANTS-ROUTES/ROUTE

#### [package](a523) `40ants-routes/route`

#### Classes

##### ROUTE

###### [class](c40a) `40ants-routes/route:route` ()

**Readers**

###### [reader](e1d4) `40ants-routes/route:route-handler` (route) (:handler)

Function to handle the route

###### [reader](e079) `40ants-routes/route:route-method` (route) (:method = :get)

`HTTP` method (`GET`, `POST`, `PUT`, etc.)

###### [reader](f77b) `40ants-routes/route:route-name` (route) (:name)

Name of the route

###### [reader](55fc) `40ants-routes/route:route-title` (route) (:title = nil)

Title for breadcrumbs

###### [reader](8221) `40ants-routes/generics:url-path` (route) (:pattern)

`URL` pattern

##### URL-PATTERN

###### [class](de0b) `40ants-routes/url-pattern:url-pattern` ()

**Readers**

###### [reader](4cbf) `40ants-routes/url-pattern:url-pattern-params` (url-pattern) (:params)

Alist with parameter types

###### [reader](8878) `40ants-routes/url-pattern:url-pattern-pattern` (url-pattern) (:pattern)

###### [reader](2180) `40ants-routes/url-pattern:url-pattern-regex` (url-pattern) (:regex)

#### Functions

##### [function](122f) `40ants-routes/route:current-route`

Returns the current route.

Should be called only during [`40ants-routes/with-url:with-url`][1c5e] macro body execution.

##### [function](18bd) `40ants-routes/route:current-route-p`

Returns T if there current route matching the `URL` was found..

Should be called only during [`40ants-routes/with-url:with-url`][1c5e]
or [`40ants-routes/with-url:with-partially-matched-url`][1a23] macro body execution.

##### [function](9264) `40ants-routes/route:routep` obj

Checks if `OBJ` is of [`route`][377c] class.

### 40ANTS-ROUTES/ROUTE-URL

#### [package](09bb) `40ants-routes/route-url`

#### Functions

##### [function](61ac) `40ants-routes/route-url:route-url` name &rest args &key namespace &allow-other-keys

Generate a `URL` for a named route with the given parameters.

### 40ANTS-ROUTES/ROUTES

#### [package](59ce) `40ants-routes/routes`

#### Classes

##### ROUTES

###### [class](52f1) `40ants-routes/routes:routes` ()

**Readers**

###### [reader](4441) `40ants-routes/routes:children-routes` (routes) (:children = nil)

List of children in this collection.

###### [reader](0986) `40ants-routes/generics:node-namespace` (routes) (:namespace)

Namespace of this routes collection.

**Accessors**

###### [accessor](4441) `40ants-routes/routes:children-routes` (routes) (:children = nil)

List of children in this collection.

###### [accessor](0986) `40ants-routes/generics:node-namespace` (routes) (:namespace)

Namespace of this routes collection.

#### Functions

##### [function](e475) `40ants-routes/routes:routesp` obj

Checks if object is of class [`routes`][cce3].

#### Macros

##### [macro](f269) `40ants-routes/routes:routes` (namespace &key (routes-class 'routes)) &body route-definitions

Define a variable holding collection of routes the same way
as [`40ants-routes/defroutes:defroutes`][3455] does, but do not bind these routes to the variable.

### 40ANTS-ROUTES/URL-PATTERN

#### [package](9930) `40ants-routes/url-pattern`

#### Classes

##### URL-PATTERN

###### [class](de0b) `40ants-routes/url-pattern:url-pattern` ()

**Readers**

###### [reader](4cbf) `40ants-routes/url-pattern:url-pattern-params` (url-pattern) (:params)

Alist with parameter types

###### [reader](8878) `40ants-routes/url-pattern:url-pattern-pattern` (url-pattern) (:pattern)

###### [reader](2180) `40ants-routes/url-pattern:url-pattern-regex` (url-pattern) (:regex)

#### Functions

##### [function](898a) `40ants-routes/url-pattern:parse-url-pattern` pattern

Parse a `URL` pattern and extract parameter specifications.

Returns an object of class [`url-pattern`][a13f].

##### [function](9829) `40ants-routes/url-pattern:url-pattern-equal` left right

Compares two [`url-pattern`][a13f] objects

##### [function](6b0c) `40ants-routes/url-pattern:url-pattern-p` obj

### 40ANTS-ROUTES/WITH-URL

#### [package](983b) `40ants-routes/with-url`

#### Macros

##### [macro](6cef) `40ants-routes/with-url:with-partially-matched-url` (root-routes url) &body body

Execute body with the current routes object corresponding to a given `URL` argument.

Difference between this macro and [`with-url`][1c5e] macro is that [`with-url`][1c5e] signals an error
if it is unable to find a leaf route matching to the whole `URL`.

[`with-partially-matched-url`][1a23] will try to find a routes path matching as much
of `URL` as possible. As the result, [`40ants-routes/route:current-route-p`][087c] function
might return `NIL` when `URL` was not fully matched by [`with-partially-matched-url`][1a23].

##### [macro](56f3) `40ants-routes/with-url:with-url` (root-routes url) &body body

Execute body with the current routes object corresponding to a given `URL` argument.

[7261]: https://40ants.com/routes
[e419]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FBREADCRUMBS-3ABREADCRUMB-20CLASS-29
[3f6e]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FBREADCRUMBS-3ABREADCRUMB-PATH-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-2040ANTS-ROUTES-2FBREADCRUMBS-3ABREADCRUMB-29-29
[920e]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FBREADCRUMBS-3ABREADCRUMB-ROUTE-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-2040ANTS-ROUTES-2FBREADCRUMBS-3ABREADCRUMB-29-29
[b28f]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FBREADCRUMBS-3ABREADCRUMB-TITLE-20-2840ANTS-DOC-2FLOCATIVES-3AREADER-2040ANTS-ROUTES-2FBREADCRUMBS-3ABREADCRUMB-29-29
[bd21]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FBREADCRUMBS-3AGET-BREADCRUMBS-20FUNCTION-29
[3455]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FDEFROUTES-3ADEFROUTES-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[f902]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FDEFROUTES-3AGET-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[2897]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FDEFROUTES-3AINCLUDE-20FUNCTION-29
[a861]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FDEFROUTES-3APOST-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[c587]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FDEFROUTES-3APUT-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[2977]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FERRORS-3ANO-ROUTE-FOR-URL-ERROR-20CONDITION-29
[3eec]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FGENERICS-3AHAS-NAMESPACE-P-20GENERIC-FUNCTION-29
[db92]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FGENERICS-3ANODE-NAMESPACE-20GENERIC-FUNCTION-29
[e530]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FHANDLER-3ACALL-HANDLER-20FUNCTION-29
[087c]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FROUTE-3ACURRENT-ROUTE-P-20FUNCTION-29
[377c]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FROUTE-3AROUTE-20CLASS-29
[fe8a]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FROUTE-URL-3AROUTE-URL-20FUNCTION-29
[77f9]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FROUTES-3AROUTES-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[cce3]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FROUTES-3AROUTES-20CLASS-29
[a13f]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FURL-PATTERN-3AURL-PATTERN-20CLASS-29
[1a23]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FWITH-URL-3AWITH-PARTIALLY-MATCHED-URL-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[1c5e]: https://40ants.com/routes/#x-2840ANTS-ROUTES-2FWITH-URL-3AWITH-URL-20-2840ANTS-DOC-2FLOCATIVES-3AMACRO-29-29
[d39a]: https://40ants.com/routes/#x-2840ANTS-ROUTES-DOCS-2FINDEX-3A-3A-40DEFINING-ROUTES-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29
[af0d]: https://40ants.com/routes/#x-2840ANTS-ROUTES-DOCS-2FINDEX-3A-3A-40MATCHING-THE-URL-2040ANTS-DOC-2FLOCATIVES-3ASECTION-29
[6959]: https://github.com/40ants/routes
[80be]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/breadcrumbs.lisp#L1
[6b1c]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/breadcrumbs.lisp#L35
[895a]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/breadcrumbs.lisp#L36
[5dcf]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/breadcrumbs.lisp#L39
[27fe]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/breadcrumbs.lisp#L42
[dec1]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/breadcrumbs.lisp#L84
[53c4]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/breadcrumbs.lisp#L92
[31be]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/defroutes.lisp#L1
[8a76]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/defroutes.lisp#L120
[bb9a]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/defroutes.lisp#L124
[aba5]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/defroutes.lisp#L128
[c5b9]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/defroutes.lisp#L140
[f7eb]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/defroutes.lisp#L34
[f269]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/defroutes.lisp#L72
[2356]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/errors.lisp#L1
[0a57]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/errors.lisp#L24
[ac63]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/errors.lisp#L35
[4370]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/errors.lisp#L49
[1b13]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/errors.lisp#L63
[8ef4]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/errors.lisp#L74
[4f03]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/errors.lisp#L85
[b185]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/find-route.lisp#L1
[3d53]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/find-route.lisp#L103
[7799]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L1
[640c]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L14
[b135]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L30
[1f44]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L42
[45ef]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L48
[5327]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L52
[222b]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L58
[7fb4]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L62
[50cd]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/generics.lisp#L68
[01b4]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/handler.lisp#L1
[4c47]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/handler.lisp#L15
[31c6]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/included-routes.lisp#L1
[3ce2]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/included-routes.lisp#L20
[b9bd]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/included-routes.lisp#L21
[43c2]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/included-routes.lisp#L25
[d0d5]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/included-routes.lisp#L39
[4e55]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/matched-route.lisp#L1
[21dc]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/matched-route.lisp#L22
[acf8]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/matched-route.lisp#L23
[40df]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/matched-route.lisp#L27
[5224]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/matched-route.lisp#L44
[09bb]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route-url.lisp#L1
[61ac]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route-url.lisp#L27
[a523]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L1
[c40a]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L32
[f77b]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L33
[8221]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L37
[e1d4]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L41
[55fc]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L45
[e079]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L50
[9264]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L68
[18bd]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L80
[122f]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/route.lisp#L88
[59ce]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/routes.lisp#L1
[52f1]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/routes.lisp#L21
[4441]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/routes.lisp#L22
[0986]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/routes.lisp#L26
[e475]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/routes.lisp#L39
[9930]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L1
[6b0c]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L172
[9829]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L179
[de0b]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L24
[8878]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L25
[2180]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L28
[4cbf]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L31
[898a]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/url-pattern.lisp#L46
[983b]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/with-url.lisp#L1
[6cef]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/with-url.lisp#L112
[56f3]: https://github.com/40ants/routes/blob/b599659e5cbe7655ff69a9d4298359de9ef65acd/src/with-url.lisp#L86
[54bf]: https://github.com/40ants/routes/issues
[8236]: https://quickdocs.org/alexandria
[49b9]: https://quickdocs.org/cl-ppcre
[c41d]: https://quickdocs.org/serapeum
[3dcd]: https://quickdocs.org/split-sequence
[ef7f]: https://quickdocs.org/str

* * *
###### [generated by [40ANTS-DOC](https://40ants.com/doc/)]