The tiny-routes Reference Manual

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

The tiny-routes Reference Manual

This is the tiny-routes Reference Manual, version 0.1.1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Thu Sep 15 06:20:37 2022 GMT+0.

Table of Contents


1 Introduction

#+TITLE:     TINY-ROUTES
#+AUTHOR:    Johnny Ruiz
#+EMAIL:     johnny@ruiz-usa.com
#+DESCRIPTION: A tiny routing library for Common Lisp targeting Clack
#+LANGUAGE:  en
#+OPTIONS:   H:4 num:nil toc:2 p:t
** Introduction
   TINY-ROUTES is a bare-bones routing library for [[https://lisp-lang.org][Common Lisp]]
   targeting the [[https://github.com/fukamachi/clack.git][Clack]] web application development. Its only external
   dependency is [[http://edicl.github.io/cl-ppcre/][CL-PPCRE]] which is used to match and bind dynamic URL
   parameters.

** Prerequisites
   The following lists the prerequisites needed to follow this
   [[https://github.com/jeko2000/tiny-routes/blob/main/README.org][README]] successfully.

   1) [[https://lispcookbook.github.io/cl-cookbook/web.html][Common Lisp web frameworks]]
      + In particular, [[http://edicl.github.io/hunchentoot/][Hunchentoot]] and [[https://github.com/fukamachi/clack.git][Clack]].
   2) [[https://developer.mozilla.org/en-US/docs/Web/HTTP][HTTP]]
      + Specifically, you should be familiar with [[https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods][HTTP methods]].
   3) [[https://www.quicklisp.org/beta/][Quicklisp]]
      + Ideally, you should have [[https://www.quicklisp.org/beta/#installation][Quicklisp installed]] and read through
        its [[https://www.quicklisp.org/beta/][documentation]].

** Motivation
   [[https://github.com/fukamachi/clack.git][Clack]]'s killer feature is that it allows us server-agnostic web
   application. Namely, web applications that are not tied to a
   specific server library such as [[http://edicl.github.io/hunchentoot/][Hunchentoot]], [[https://github.com/gigamonkey/toot][Toot]], or [[https://github.com/orthecreedence/wookie][Wookie]].

   Clack distills a web application down to just a =handler= function
   that accepts a =request= (or an =environment=) object (i.e., a
   [[https://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node108.html][plist]] containing data like HTTP request method, request URI, among
   others) and returns an appropriate HTTP response. This HTTP
   response is represented simply by a list of three elements
   containing the HTTP status code, HTTP headers, and a response body.

   This simplification provides developers with a great amount of
   flexibility given that we can leverage the entire power of lisp to
   create these simple list structures representing HTTP responses.
   However, I quickly found that [[https://github.com/fukamachi/clack.git][Clack]]' itself does not offer tools or
   guidance on how such request =handler= functions should be written,
   composed, and ultimately managed.

   The purpose of TINY-ROUTES is to provide a small set of
   helper/utility functions and macros to aid the developer in
   building clack applications by breaking them up into composable
   request handlers and middleware functions.

** Definitions
   The following represents definitions used in this document.

   + =request= or =environemnt= :: A plist representing an HTTP
     request. Please see [[https://github.com/fukamachi/clack.git][Clack]] for a list of supported fields.
     Finally, please note that users and/or middleware are allowed
     (and encouraged!) to add new fields to the request object for new
     functionality.

   + =response= :: A list or lambda representing an HTTP response. Per
     the [[https://github.com/fukamachi/clack.git][Clack]] documentation, a response can either be:
      1) A list of three elements representing an HTTP status code,
         HTTP headers, and a response body

      2) A lambda accepting a =response= function to be called with a
         =response= asynchronously.

   + =handler= :: A function that accepts a =request= and returns a
     =response= or nil.

   + =middleware= :: A combinator function that accepts a handler as
     its first argument, optionally accepts other arguments, and
     returns a potentially different handler.

** Usage
   The following application exposes:
   + A static endpoint which returns an HTTP 200 response with the body
     =alive=
   + A dynamic endpoint which returns an HTTP 200 response with a
     string containing the bound value =account-
   + A catch-all handler which returns an HTTP 404 response with the
     body =not-found=.
   #+begin_src common-lisp
(define-routes *app*                                          ; (1)
  (define-get "/" ()                                          ; (2)
    (ok "alive"))                                             ; (3)
  (define-get "/accounts/:account-id" (request)               ; (4)
    (let ((account-id (path-param request :account-id)))      ; (5)
      (ok (format nil "Your account id: ~a." account-id))))   ; (6)
  (define-any "*" ()                                          ; (7)
    (not-found "not-found")))                                 ; (8)
   #+end_src
   Each line in the example is detailed below
   1) The =define-routes= macro accepts a variable number of handlers
      and returns a new handler that loops through each handler and
      returns the first non-nil response it finds.
   2) The =define-get= macro creates a handler that matches on HTTP GET
      requests. The macro accepts a =path-template= and a request
      binding. Please note TINY-ROUTES also exposes similar macros for
      POST, PUT, HEADER, HEAD, and OPTIONS.
   3) The =ok= function accepts an optional body and returns a
      response list with HTTP status 200 OK.
   4) The =define-get= macro now receives a path-template with a
      dynamic parameter named =:account-id=. This value associated
      with this dynamic parameter is made available as part of the
      request's path-params as seen in line (5).
   5) The =path-param= selector function can be used to quickly parse
      a path param from a request object.
   6) We leverage the =format= function to show that the response body
      can also be dynamic.
   7) The =define-any= macro can be used to implement _catch all_
      routes.
   8) The =not-found= function accepts an optional body and returns a
      response list with HTTP status 404 Not Found.

** Installation
   To install via [[https://www.quicklisp.org/beta/][quicklisp]] please run the following in your running REPL:
   #+begin_src common-lisp
(ql:quickload "tiny-routes")
   #+end_src
** Sample code
   Please see [[https://github.com/jeko2000/tiny-routes-realworld-example-app][tiny-routes-realworld-example-app]] for a full-fledged
   [[https://github.com/fukamachi/clack.git][Clack]] REST application demonstrating one possible use of
   [[https://github.com/jeko2000/tiny-routes/][tiny-routes]].

   Enjoy!


2 Systems

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


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

2.1 tiny-routes

A tiny routing library for Common Lisp targeting Clack.

Author

Johnny Ruiz <johnny@ruiz-usa.com>

License

BSD 3-Clause

Version

0.1.1

Dependencies
  • cl-ppcre (system).
  • uiop (system).
Source

tiny-routes.asd.

Child Components

3 Modules

Modules are listed depth-first from the system components tree.


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

3.1 tiny-routes/middleware

Dependency

response.lisp (file).

Source

tiny-routes.asd.

Parent Component

tiny-routes (system).

Child Components

4 Files

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


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

4.1 Lisp


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

4.1.1 tiny-routes/tiny-routes.asd

Source

tiny-routes.asd.

Parent Component

tiny-routes (system).

ASDF Systems

tiny-routes.


4.1.2 tiny-routes/util.lisp

Source

tiny-routes.asd.

Parent Component

tiny-routes (system).

Packages

tiny-routes.util.

Public Interface

4.1.3 tiny-routes/request.lisp

Dependency

util.lisp (file).

Source

tiny-routes.asd.

Parent Component

tiny-routes (system).

Packages

tiny-routes.request.

Public Interface

4.1.4 tiny-routes/response.lisp

Dependency

request.lisp (file).

Source

tiny-routes.asd.

Parent Component

tiny-routes (system).

Packages

tiny-routes.response.

Public Interface
Internals

4.1.5 tiny-routes/middleware/builder.lisp

Source

tiny-routes.asd.

Parent Component

middleware (module).

Packages

tiny-routes.middleware.builder.

Public Interface

4.1.6 tiny-routes/middleware/method.lisp

Dependency

builder.lisp (file).

Source

tiny-routes.asd.

Parent Component

middleware (module).

Packages

tiny-routes.middleware.method.

Public Interface

wrap-request-matches-method (function).


4.1.7 tiny-routes/middleware/path-template.lisp

Dependency

method.lisp (file).

Source

tiny-routes.asd.

Parent Component

middleware (module).

Packages

tiny-routes.middleware.path-template.

Public Interface
Internals

4.1.8 tiny-routes/middleware/query-parameters.lisp

Dependency

path-template.lisp (file).

Source

tiny-routes.asd.

Parent Component

middleware (module).

Packages

tiny-routes.middleware.query-parameters.

Public Interface

4.1.9 tiny-routes/middleware/request-body.lisp

Dependency

query-parameters.lisp (file).

Source

tiny-routes.asd.

Parent Component

middleware (module).

Packages

tiny-routes.middleware.request-body.

Public Interface

4.1.10 tiny-routes/middleware/response.lisp

Dependency

request-body.lisp (file).

Source

tiny-routes.asd.

Parent Component

middleware (module).

Packages

tiny-routes.middleware.response.

Public Interface

4.1.11 tiny-routes/middleware/middleware.lisp

Dependency

response.lisp (file).

Source

tiny-routes.asd.

Parent Component

middleware (module).

Packages

tiny-routes.middleware.


4.1.12 tiny-routes/tiny-routes.lisp

Dependency

middleware (module).

Source

tiny-routes.asd.

Parent Component

tiny-routes (system).

Packages

tiny-routes.

Public Interface
Internals

prepare-route (macro).


5 Packages

Packages are listed by definition order.


5.1 tiny-routes.middleware.method

Source

method.lisp.

Use List

common-lisp.

Used By List

tiny-routes.middleware.

Public Interface

wrap-request-matches-method (function).


5.2 tiny-routes.middleware.builder

Source

builder.lisp.

Use List

common-lisp.

Used By List

tiny-routes.middleware.

Public Interface

5.3 tiny-routes.middleware.query-parameters

Source

query-parameters.lisp.

Use List

common-lisp.

Used By List

tiny-routes.middleware.

Public Interface

5.4 tiny-routes.request

Source

request.lisp.

Use List

common-lisp.

Used By List

tiny-routes.

Public Interface

5.5 tiny-routes.middleware.response

Source

response.lisp.

Use List

common-lisp.

Used By List

tiny-routes.middleware.

Public Interface

5.6 tiny-routes.response

Source

response.lisp.

Use List

common-lisp.

Used By List

tiny-routes.

Public Interface
Internals

5.7 tiny-routes

Source

tiny-routes.lisp.

Nickname

tiny

Use List
Public Interface
Internals

prepare-route (macro).


5.8 tiny-routes.middleware.request-body

Source

request-body.lisp.

Use List

common-lisp.

Used By List

tiny-routes.middleware.

Public Interface

5.9 tiny-routes.middleware.path-template

Source

path-template.lisp.

Use List

common-lisp.

Used By List

tiny-routes.middleware.

Public Interface
Internals

5.10 tiny-routes.util

Source

util.lisp.

Use List

common-lisp.

Used By List

tiny-routes.

Public Interface

6 Definitions

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


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

6.1 Public Interface


6.1.1 Macros

Macro: define-any (path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-delete (path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-get (path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-head (path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-options (path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-post (path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-put (path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-route (req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: define-routes (name &body handlers)

Define a route handler from ROUTES

Package

tiny-routes.

Source

tiny-routes.lisp.

Macro: pipe (value &body wrappers)

Pipe VALUE through WRAPPERS by subsequently passing each wrapped value as the first parameter of the next wrapper.

Package

tiny-routes.util.

Source

util.lisp.

Macro: with-request (request-vars request &body body)

Bind the variables in REQUEST-VARS to the corresponding values in REQUEST and evaluate BODY. Each var in REQUEST-VARS can either be a symbol or a list in the form (variable-name keyword-name [default-value]).

Package

tiny-routes.request.

Source

request.lisp.


6.1.2 Compiler macros

Compiler Macro: body-mapper-response (&rest args)
Package

tiny-routes.response.

Source

response.lisp.

Compiler Macro: body-response (&rest args)
Package

tiny-routes.response.

Source

response.lisp.

Compiler Macro: header-response (&rest args)
Package

tiny-routes.response.

Source

response.lisp.

Compiler Macro: headers-response (&rest args)
Package

tiny-routes.response.

Source

response.lisp.

Compiler Macro: headers-response-append (&rest args)
Package

tiny-routes.response.

Source

response.lisp.

Compiler Macro: status-response (&rest args)
Package

tiny-routes.response.

Source

response.lisp.


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

6.1.3 Ordinary functions

Function: accepted (&optional body)

Return a response with status HTTP 202 Accepted and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: bad-request (&optional body)

Return a response with status HTTP 400 Bad Request and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: body-mapper-response (response body-mapper)

Return a clone of RESPONSE where body is mapped via BODY-MAPPER. DEPRECATED. Please use ‘tiny:clone-response’ instead.

Package

tiny-routes.response.

Source

response.lisp.

Function: body-response (response body)

Return a clone of RESPONSE with BODY.
DEPRECATED. Please use ‘tiny:clone-response’ instead.

Package

tiny-routes.response.

Source

response.lisp.

Function: clack.io (request &optional default)

Return the clack.io from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: clack.streaming (request &optional default)

Return the the clack.streaming from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: clone-response (response &rest args &key status headers body)

Return a clone of RESPONSE with the provided STATUS, HEADERS, and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: compose (function &rest other-functions)
Package

tiny-routes.util.

Source

util.lisp.

Function: conflict (&optional body)

Return a response with status HTTP 409 Conflict and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: content-length (request &optional default)

Return the content length from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: content-type (request &optional default)

Return the content type from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: created (location &optional body)

Return a response with status HTTP 201 Created with a location header of LOCATION and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: forbidden (&optional body)

Return a response with status HTTP 403 Forbidden and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: header-response (response key value)

Return a clone of RESPONSE with header KEY and VALUE added. DEPRECATED. Please use ‘tiny:clone-response’ instead.

Package

tiny-routes.response.

Source

response.lisp.

Function: headers-response (response headers)

Return a clone of RESPONSE with HEADERS. DEPRECATED. Please use ‘tiny:clone-response’ instead.

Package

tiny-routes.response.

Source

response.lisp.

Function: headers-response-append (response header-key header-value)

Return a clone of RESPONSE with HEADER-KEY and HEADER-VALUE added. DEPRECATED. Please use ‘tiny:clone-response’ instead.

Package

tiny-routes.response.

Source

response.lisp.

Function: internal-server-error (&optional body)

Return a response with status HTTP 500 Internal Server Error and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: make-request (&rest args &key request-uri request-method path-info url-scheme &allow-other-keys)

Return a new request based on ARGS.

Package

tiny-routes.request.

Source

request.lisp.

Function: make-response (&key status headers body)

Return a new response with HTTP STATUS, HEADERS, and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: method-not-allowed (&optional body)

Return a response with status HTTP 405 Method Not Allowed and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: no-content ()

Return a response with status HTTP 204 No Content.

Package

tiny-routes.response.

Source

response.lisp.

Function: not-acceptable (&optional body)

Return a response with status HTTP 406 Not Acceptable and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: not-found (&optional body)

Return a response with status HTTP 404 Not Found and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: not-implemented (&optional body)

Return a response with status HTTP 500 Not Implemented and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: ok (&optional body)

Return a response with status HTTP 200 OK and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: parse-query-parameters (query-string)
Package

tiny-routes.middleware.query-parameters.

Source

query-parameters.lisp.

Function: path-info (request &optional default)

Return the path info from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: payload-too-large (&optional body)

Return a response with status HTTP 413 Payload Too Large and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: query-string (request &optional default)

Return the query string from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: raw-body (request &optional default)

Return the raw body from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: read-stream-to-string (input-stream)

Read INPUT-STREAM entirely and return the contents as a string.

Package

tiny-routes.middleware.request-body.

Source

request-body.lisp.

Function: redirect (location &optional status)

Return a response with STATUS and with a location header of LOCATION.

Package

tiny-routes.response.

Source

response.lisp.

Function: remote-address (request &optional default)

Return the remote address from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: remote-port (request &optional default)

Return the remote port from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: request-append (request key value)

Return a clone of REQUEST containing KEY and VALUE.

Package

tiny-routes.request.

Source

request.lisp.

Function: request-body (request &optional default)

Return the request body from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: request-get (request key &optional default)

Return the value associated with KEY in REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: request-header (request key &optional default)

Return the header value from REQUEST associated with KEY or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: request-headers (request &optional default)

Return the headers from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: request-method (request &optional default)

Return the request method from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: requestp (object)

Return t if OBJECT is a request.

Package

tiny-routes.request.

Source

request.lisp.

Function: response-body (response)

Return the RESPONSE body.

Package

tiny-routes.response.

Source

response.lisp.

Function: response-header (response key &optional default)

Return the value of KEY from the headers of RESPONSE.

Package

tiny-routes.response.

Source

response.lisp.

Function: response-headers (response)

Return the headers of RESPONSE.

Package

tiny-routes.response.

Source

response.lisp.

Function: response-status (response)

Return the status of RESPONSE.

Package

tiny-routes.response.

Source

response.lisp.

Function: responsep (object)

Return t if OBJECT is a response.

Package

tiny-routes.response.

Source

response.lisp.

Function: routes (&rest handlers)

Return a handler which itself calls each handler in HANDLERS and returns the first non-nil response. Otherwise, return nil.

Package

tiny-routes.

Source

tiny-routes.lisp.

Function: script-name (request &optional default)

Return the script name from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: server-name (request &optional default)

Return the server name from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: server-port (request &optional default)

Return the server port from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: server-protocol (request &optional default)

Return the server protocol from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: status-response (response status)

Return a clone of RESPONSE with STATUS. DEPRECATED. Please use ‘tiny:clone-response’ instead.

Package

tiny-routes.response.

Source

response.lisp.

Function: unauthorized (&optional body)

Return a response with status HTTP 401 Unauthorized and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: unprocessable-entity (&optional body)

Return a response with status HTTP 422 Unprocessable Entity and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: unsupported-media-type (&optional body)

Return a response with status HTTP 415 Unsupported Media Type and BODY.

Package

tiny-routes.response.

Source

response.lisp.

Function: uri (request &optional default)

Return the request URI from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: url-scheme (request &optional default)

Return the URL scheme from REQUEST or DEFAULT.

Package

tiny-routes.request.

Source

request.lisp.

Function: wrap-middleware-internal (handler)

Wrap HANDLER such that post-match handlers are called.

Package

tiny-routes.

Source

tiny-routes.lisp.

Function: wrap-post-match-middleware (handler middleware)

Wrap HANDLER such that MIDDLEWARE is wrapped after the request is matched.

Package

tiny-routes.

Source

tiny-routes.lisp.

Function: wrap-query-parameters (handler &key query-parameter-parser)

Wrap HANDLER such that the results of applying QUERY-PARAMETER-PARSER to the query string is made available to the request via ‘:query-parameters’.

Package

tiny-routes.middleware.query-parameters.

Source

query-parameters.lisp.

Function: wrap-request-body (handler &key input-stream-mapper)

Wrap HANDLER such that the result of applying INPUT-STREAM-MAPPER to the request body is made available to the request via ‘:request-body’.

Package

tiny-routes.middleware.request-body.

Source

request-body.lisp.

Function: wrap-request-mapper (handler request-mapper)

Return a new handler that calls HANDLER with the result of applying REQUEST-MAPPER to request.

Package

tiny-routes.middleware.builder.

Source

builder.lisp.

Function: wrap-request-matches-method (handler method)

Wrap HANDLER such that it is called only if the request method matches METHOD.

If METHOD is t, nil or ‘:any’, then return HANDLER unchanged.

If METHOD is a list, then wrap handler such that it is called only if
the request method is in the list.

Package

tiny-routes.middleware.method.

Source

method.lisp.

Function: wrap-request-matches-path-template (handler path-template &key regex)

Wrap HANDLER such that it is called only if the request path matches the PATH-TEMPLATE.

If PATH-TEMPLATE is t, nil, or an empty string, then return HANDLER unchanged.

If REGEX is non-nil, then interpret path-template as a regular expression.

Package

tiny-routes.middleware.path-template.

Source

path-template.lisp.

Function: wrap-request-path-info-matcher (handler path-info-matcher)

Wrap HANDLER such that it is called only if the result of applying PATH-INFO-MATCHER to the request’s path-info returns non-nil.

If the result of applying PATH-INFO-MATCHER to the request is a list, then it is made available to the request under ‘:path-parameters’.

Package

tiny-routes.middleware.path-template.

Source

path-template.lisp.

Function: wrap-request-predicate (handler request-predicate)

Returns a new handler that calls HANDLER only if the request satisfies REQUEST-PREDICATE.

Package

tiny-routes.middleware.builder.

Source

builder.lisp.

Function: wrap-response-body (handler body)
Package

tiny-routes.middleware.response.

Source

response.lisp.

Function: wrap-response-body-mapper (handler body-mapper)
Package

tiny-routes.middleware.response.

Source

response.lisp.

Function: wrap-response-content-type (handler content-type)

Wrap HANDLER such that the response content type is set to CONTENT-TYPE.

Package

tiny-routes.middleware.response.

Source

response.lisp.

Function: wrap-response-header (handler key value)

Wrap HANDLER such that the response headers includes header with KEY and VALUE.

Package

tiny-routes.middleware.response.

Source

response.lisp.

Function: wrap-response-headers (handler headers)

Wrap HANDLER such that the response headers are set to HEADERS.

Package

tiny-routes.middleware.response.

Source

response.lisp.

Function: wrap-response-mapper (handler response-mapper)

Wrap HANDLER such that it returns the result of applying RESPONSE-MAPPER to response.

Package

tiny-routes.middleware.builder.

Source

builder.lisp.

Function: wrap-response-mapper* (handler bi-mapper)

Wrap HANDLER such that it returns the result of applying BI-MAPPER to request and response.

Package

tiny-routes.middleware.builder.

Source

builder.lisp.

Function: wrap-response-status (handler status)

Wrap HANDLER such that the response status is set to STATUS.

Package

tiny-routes.middleware.response.

Source

response.lisp.


6.1.4 Types

Type: request ()
Package

tiny-routes.request.

Source

request.lisp.

Type: response ()
Package

tiny-routes.response.

Source

response.lisp.


6.2 Internals


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

6.2.1 Special variables

Special Variable: *deprecated-function-style-warning-body-mapper-response-notified-p*
Package

tiny-routes.response.

Source

response.lisp.

Special Variable: *deprecated-function-style-warning-body-response-notified-p*
Package

tiny-routes.response.

Source

response.lisp.

Special Variable: *deprecated-function-style-warning-header-response-notified-p*
Package

tiny-routes.response.

Source

response.lisp.

Special Variable: *deprecated-function-style-warning-headers-response-append-notified-p*
Package

tiny-routes.response.

Source

response.lisp.

Special Variable: *deprecated-function-style-warning-headers-response-notified-p*
Package

tiny-routes.response.

Source

response.lisp.

Special Variable: *deprecated-function-style-warning-status-response-notified-p*
Package

tiny-routes.response.

Source

response.lisp.

Special Variable: *path-token-scanner*

The cl-ppcre scanner that matches against a path token such as :id in /articles/:id.

Package

tiny-routes.middleware.path-template.

Source

path-template.lisp.


6.2.2 Macros

Macro: prepare-route (method path-template req-binding &body body)
Package

tiny-routes.

Source

tiny-routes.lisp.


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

6.2.3 Ordinary functions

Function: make-path-template-exact-matcher (path-template)

Return a closure that accepts a path and returns t when path matches PATH-TEMPLATE.

Package

tiny-routes.middleware.path-template.

Source

path-template.lisp.

Function: make-path-template-keyword-matcher (path-template)

Return a closure that accepts a path and returns an plist of matched groups when path matches PATH-TEMPLATE.

For example, a path template for "/users/:user-id" when matched against "/users/1042" returns ‘(:user-id "jeko")’.

Package

tiny-routes.middleware.path-template.

Source

path-template.lisp.

Function: make-path-template-regex-matcher (path-template)

Return a closure that accepts a path and returns non-nil if path matches the regex in PATH-TEMPLATE.

Package

tiny-routes.middleware.path-template.

Source

path-template.lisp.

Function: synchronous-response-p (object)

Return t if OBJECT is a synchronous response.

Package

tiny-routes.response.

Source

response.lisp.

Function: too-many-requests (&optional body)

Return a response with status HTTP 429 Too Many Requests and BODY.

Package

tiny-routes.response.

Source

response.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   B   C   D   F   H   I   M   N   O   P   Q   R   S   T   U   W  
Index Entry  Section

A
accepted: Public ordinary functions

B
bad-request: Public ordinary functions
body-mapper-response: Public compiler macros
body-mapper-response: Public ordinary functions
body-response: Public compiler macros
body-response: Public ordinary functions

C
clack.io: Public ordinary functions
clack.streaming: Public ordinary functions
clone-response: Public ordinary functions
Compiler Macro, body-mapper-response: Public compiler macros
Compiler Macro, body-response: Public compiler macros
Compiler Macro, header-response: Public compiler macros
Compiler Macro, headers-response: Public compiler macros
Compiler Macro, headers-response-append: Public compiler macros
Compiler Macro, status-response: Public compiler macros
compose: Public ordinary functions
conflict: Public ordinary functions
content-length: Public ordinary functions
content-type: Public ordinary functions
created: Public ordinary functions

D
define-any: Public macros
define-delete: Public macros
define-get: Public macros
define-head: Public macros
define-options: Public macros
define-post: Public macros
define-put: Public macros
define-route: Public macros
define-routes: Public macros

F
forbidden: Public ordinary functions
Function, accepted: Public ordinary functions
Function, bad-request: Public ordinary functions
Function, body-mapper-response: Public ordinary functions
Function, body-response: Public ordinary functions
Function, clack.io: Public ordinary functions
Function, clack.streaming: Public ordinary functions
Function, clone-response: Public ordinary functions
Function, compose: Public ordinary functions
Function, conflict: Public ordinary functions
Function, content-length: Public ordinary functions
Function, content-type: Public ordinary functions
Function, created: Public ordinary functions
Function, forbidden: Public ordinary functions
Function, header-response: Public ordinary functions
Function, headers-response: Public ordinary functions
Function, headers-response-append: Public ordinary functions
Function, internal-server-error: Public ordinary functions
Function, make-path-template-exact-matcher: Private ordinary functions
Function, make-path-template-keyword-matcher: Private ordinary functions
Function, make-path-template-regex-matcher: Private ordinary functions
Function, make-request: Public ordinary functions
Function, make-response: Public ordinary functions
Function, method-not-allowed: Public ordinary functions
Function, no-content: Public ordinary functions
Function, not-acceptable: Public ordinary functions
Function, not-found: Public ordinary functions
Function, not-implemented: Public ordinary functions
Function, ok: Public ordinary functions
Function, parse-query-parameters: Public ordinary functions
Function, path-info: Public ordinary functions
Function, payload-too-large: Public ordinary functions
Function, query-string: Public ordinary functions
Function, raw-body: Public ordinary functions
Function, read-stream-to-string: Public ordinary functions
Function, redirect: Public ordinary functions
Function, remote-address: Public ordinary functions
Function, remote-port: Public ordinary functions
Function, request-append: Public ordinary functions
Function, request-body: Public ordinary functions
Function, request-get: Public ordinary functions
Function, request-header: Public ordinary functions
Function, request-headers: Public ordinary functions
Function, request-method: Public ordinary functions
Function, requestp: Public ordinary functions
Function, response-body: Public ordinary functions
Function, response-header: Public ordinary functions
Function, response-headers: Public ordinary functions
Function, response-status: Public ordinary functions
Function, responsep: Public ordinary functions
Function, routes: Public ordinary functions
Function, script-name: Public ordinary functions
Function, server-name: Public ordinary functions
Function, server-port: Public ordinary functions
Function, server-protocol: Public ordinary functions
Function, status-response: Public ordinary functions
Function, synchronous-response-p: Private ordinary functions
Function, too-many-requests: Private ordinary functions
Function, unauthorized: Public ordinary functions
Function, unprocessable-entity: Public ordinary functions
Function, unsupported-media-type: Public ordinary functions
Function, uri: Public ordinary functions
Function, url-scheme: Public ordinary functions
Function, wrap-middleware-internal: Public ordinary functions
Function, wrap-post-match-middleware: Public ordinary functions
Function, wrap-query-parameters: Public ordinary functions
Function, wrap-request-body: Public ordinary functions
Function, wrap-request-mapper: Public ordinary functions
Function, wrap-request-matches-method: Public ordinary functions
Function, wrap-request-matches-path-template: Public ordinary functions
Function, wrap-request-path-info-matcher: Public ordinary functions
Function, wrap-request-predicate: Public ordinary functions
Function, wrap-response-body: Public ordinary functions
Function, wrap-response-body-mapper: Public ordinary functions
Function, wrap-response-content-type: Public ordinary functions
Function, wrap-response-header: Public ordinary functions
Function, wrap-response-headers: Public ordinary functions
Function, wrap-response-mapper: Public ordinary functions
Function, wrap-response-mapper*: Public ordinary functions
Function, wrap-response-status: Public ordinary functions

H
header-response: Public compiler macros
header-response: Public ordinary functions
headers-response: Public compiler macros
headers-response: Public ordinary functions
headers-response-append: Public compiler macros
headers-response-append: Public ordinary functions

I
internal-server-error: Public ordinary functions

M
Macro, define-any: Public macros
Macro, define-delete: Public macros
Macro, define-get: Public macros
Macro, define-head: Public macros
Macro, define-options: Public macros
Macro, define-post: Public macros
Macro, define-put: Public macros
Macro, define-route: Public macros
Macro, define-routes: Public macros
Macro, pipe: Public macros
Macro, prepare-route: Private macros
Macro, with-request: Public macros
make-path-template-exact-matcher: Private ordinary functions
make-path-template-keyword-matcher: Private ordinary functions
make-path-template-regex-matcher: Private ordinary functions
make-request: Public ordinary functions
make-response: Public ordinary functions
method-not-allowed: Public ordinary functions

N
no-content: Public ordinary functions
not-acceptable: Public ordinary functions
not-found: Public ordinary functions
not-implemented: Public ordinary functions

O
ok: Public ordinary functions

P
parse-query-parameters: Public ordinary functions
path-info: Public ordinary functions
payload-too-large: Public ordinary functions
pipe: Public macros
prepare-route: Private macros

Q
query-string: Public ordinary functions

R
raw-body: Public ordinary functions
read-stream-to-string: Public ordinary functions
redirect: Public ordinary functions
remote-address: Public ordinary functions
remote-port: Public ordinary functions
request-append: Public ordinary functions
request-body: Public ordinary functions
request-get: Public ordinary functions
request-header: Public ordinary functions
request-headers: Public ordinary functions
request-method: Public ordinary functions
requestp: Public ordinary functions
response-body: Public ordinary functions
response-header: Public ordinary functions
response-headers: Public ordinary functions
response-status: Public ordinary functions
responsep: Public ordinary functions
routes: Public ordinary functions

S
script-name: Public ordinary functions
server-name: Public ordinary functions
server-port: Public ordinary functions
server-protocol: Public ordinary functions
status-response: Public compiler macros
status-response: Public ordinary functions
synchronous-response-p: Private ordinary functions

T
too-many-requests: Private ordinary functions

U
unauthorized: Public ordinary functions
unprocessable-entity: Public ordinary functions
unsupported-media-type: Public ordinary functions
uri: Public ordinary functions
url-scheme: Public ordinary functions

W
with-request: Public macros
wrap-middleware-internal: Public ordinary functions
wrap-post-match-middleware: Public ordinary functions
wrap-query-parameters: Public ordinary functions
wrap-request-body: Public ordinary functions
wrap-request-mapper: Public ordinary functions
wrap-request-matches-method: Public ordinary functions
wrap-request-matches-path-template: Public ordinary functions
wrap-request-path-info-matcher: Public ordinary functions
wrap-request-predicate: Public ordinary functions
wrap-response-body: Public ordinary functions
wrap-response-body-mapper: Public ordinary functions
wrap-response-content-type: Public ordinary functions
wrap-response-header: Public ordinary functions
wrap-response-headers: Public ordinary functions
wrap-response-mapper: Public ordinary functions
wrap-response-mapper*: Public ordinary functions
wrap-response-status: Public ordinary functions

Jump to:   A   B   C   D   F   H   I   M   N   O   P   Q   R   S   T   U   W  

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

A.4 Data types

Jump to:   B   F   M   P   Q   R   S   T   U  
Index Entry  Section

B
builder.lisp: The tiny-routes/middleware/builder․lisp file

F
File, builder.lisp: The tiny-routes/middleware/builder․lisp file
File, method.lisp: The tiny-routes/middleware/method․lisp file
File, middleware.lisp: The tiny-routes/middleware/middleware․lisp file
File, path-template.lisp: The tiny-routes/middleware/path-template․lisp file
File, query-parameters.lisp: The tiny-routes/middleware/query-parameters․lisp file
File, request-body.lisp: The tiny-routes/middleware/request-body․lisp file
File, request.lisp: The tiny-routes/request․lisp file
File, response.lisp: The tiny-routes/response․lisp file
File, response.lisp: The tiny-routes/middleware/response․lisp file
File, tiny-routes.asd: The tiny-routes/tiny-routes․asd file
File, tiny-routes.lisp: The tiny-routes/tiny-routes․lisp file
File, util.lisp: The tiny-routes/util․lisp file

M
method.lisp: The tiny-routes/middleware/method․lisp file
middleware: The tiny-routes/middleware module
middleware.lisp: The tiny-routes/middleware/middleware․lisp file
Module, middleware: The tiny-routes/middleware module

P
Package, tiny-routes: The tiny-routes package
Package, tiny-routes.middleware: The tiny-routes․middleware package
Package, tiny-routes.middleware.builder: The tiny-routes․middleware․builder package
Package, tiny-routes.middleware.method: The tiny-routes․middleware․method package
Package, tiny-routes.middleware.path-template: The tiny-routes․middleware․path-template package
Package, tiny-routes.middleware.query-parameters: The tiny-routes․middleware․query-parameters package
Package, tiny-routes.middleware.request-body: The tiny-routes․middleware․request-body package
Package, tiny-routes.middleware.response: The tiny-routes․middleware․response package
Package, tiny-routes.request: The tiny-routes․request package
Package, tiny-routes.response: The tiny-routes․response package
Package, tiny-routes.util: The tiny-routes․util package
path-template.lisp: The tiny-routes/middleware/path-template․lisp file

Q
query-parameters.lisp: The tiny-routes/middleware/query-parameters․lisp file

R
request: Public types
request-body.lisp: The tiny-routes/middleware/request-body․lisp file
request.lisp: The tiny-routes/request․lisp file
response: Public types
response.lisp: The tiny-routes/response․lisp file
response.lisp: The tiny-routes/middleware/response․lisp file

S
System, tiny-routes: The tiny-routes system

T
tiny-routes: The tiny-routes system
tiny-routes: The tiny-routes package
tiny-routes.asd: The tiny-routes/tiny-routes․asd file
tiny-routes.lisp: The tiny-routes/tiny-routes․lisp file
tiny-routes.middleware: The tiny-routes․middleware package
tiny-routes.middleware.builder: The tiny-routes․middleware․builder package
tiny-routes.middleware.method: The tiny-routes․middleware․method package
tiny-routes.middleware.path-template: The tiny-routes․middleware․path-template package
tiny-routes.middleware.query-parameters: The tiny-routes․middleware․query-parameters package
tiny-routes.middleware.request-body: The tiny-routes․middleware․request-body package
tiny-routes.middleware.response: The tiny-routes․middleware․response package
tiny-routes.request: The tiny-routes․request package
tiny-routes.response: The tiny-routes․response package
tiny-routes.util: The tiny-routes․util package
Type, request: Public types
Type, response: Public types

U
util.lisp: The tiny-routes/util․lisp file

Jump to:   B   F   M   P   Q   R   S   T   U