The tiny-routes Reference Manual

Table of Contents

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 3.0 "Montgomery Scott" on Sun May 15 06:17:37 2022 GMT+0.


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

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!


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

2 Systems

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


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

2.1 tiny-routes

Author

Johnny Ruiz <johnny@ruiz-usa.com>

License

BSD 3-Clause

Description

A tiny routing library for Common Lisp targeting Clack.

Version

0.1.1

Dependencies
Source

tiny-routes.asd (file)

Components

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

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)

Parent

tiny-routes (system)

Location

middleware/

Components

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

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 files   [Contents][Index]

4.1.1 tiny-routes.asd

Location

/home/quickref/quicklisp/dists/quicklisp/software/tiny-routes-20220331-git/tiny-routes.asd

Systems

tiny-routes (system)


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

4.1.2 tiny-routes/util.lisp

Parent

tiny-routes (system)

Location

util.lisp

Packages

tiny-routes.util

Exported Definitions

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

4.1.3 tiny-routes/request.lisp

Dependency

util.lisp (file)

Parent

tiny-routes (system)

Location

request.lisp

Packages

tiny-routes.request

Exported Definitions

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

4.1.4 tiny-routes/response.lisp

Dependency

request.lisp (file)

Parent

tiny-routes (system)

Location

response.lisp

Packages

tiny-routes.response

Exported Definitions
Internal Definitions

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

4.1.5 tiny-routes/middleware/builder.lisp

Parent

middleware (module)

Location

middleware/builder.lisp

Packages

tiny-routes.middleware.builder

Exported Definitions

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

4.1.6 tiny-routes/middleware/method.lisp

Dependency

builder.lisp (file)

Parent

middleware (module)

Location

middleware/method.lisp

Packages

tiny-routes.middleware.method

Exported Definitions

wrap-request-matches-method (function)


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

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

Dependency

method.lisp (file)

Parent

middleware (module)

Location

middleware/path-template.lisp

Packages

tiny-routes.middleware.path-template

Exported Definitions
Internal Definitions

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

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

Dependency

path-template.lisp (file)

Parent

middleware (module)

Location

middleware/query-parameters.lisp

Packages

tiny-routes.middleware.query-parameters

Exported Definitions

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

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

Dependency

query-parameters.lisp (file)

Parent

middleware (module)

Location

middleware/request-body.lisp

Packages

tiny-routes.middleware.request-body

Exported Definitions

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

4.1.10 tiny-routes/middleware/response.lisp

Dependency

request-body.lisp (file)

Parent

middleware (module)

Location

middleware/response.lisp

Packages

tiny-routes.middleware.response

Exported Definitions

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

4.1.11 tiny-routes/middleware/middleware.lisp

Dependency

response.lisp (file)

Parent

middleware (module)

Location

middleware/middleware.lisp

Packages

tiny-routes.middleware


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

4.1.12 tiny-routes/tiny-routes.lisp

Dependency

middleware (module)

Parent

tiny-routes (system)

Location

tiny-routes.lisp

Packages

tiny-routes

Exported Definitions
Internal Definitions

prepare-route (macro)


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

5 Packages

Packages are listed by definition order.


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

5.1 tiny-routes.util

Source

util.lisp (file)

Use List

common-lisp

Used By List

tiny-routes

Exported Definitions

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

5.2 tiny-routes.request

Source

request.lisp (file)

Use List

common-lisp

Used By List

tiny-routes

Exported Definitions

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

5.3 tiny-routes.response

Source

response.lisp (file)

Use List

common-lisp

Used By List

tiny-routes

Exported Definitions
Internal Definitions

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

5.4 tiny-routes.middleware.builder

Source

builder.lisp (file)

Use List

common-lisp

Used By List

tiny-routes.middleware

Exported Definitions

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

5.5 tiny-routes.middleware.method

Source

method.lisp (file)

Use List

common-lisp

Used By List

tiny-routes.middleware

Exported Definitions

wrap-request-matches-method (function)


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

5.6 tiny-routes.middleware.path-template

Source

path-template.lisp (file)

Use List

common-lisp

Used By List

tiny-routes.middleware

Exported Definitions
Internal Definitions

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

5.7 tiny-routes.middleware.query-parameters

Source

query-parameters.lisp (file)

Use List

common-lisp

Used By List

tiny-routes.middleware

Exported Definitions

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

5.8 tiny-routes.middleware.request-body

Source

request-body.lisp (file)

Use List

common-lisp

Used By List

tiny-routes.middleware

Exported Definitions

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

5.9 tiny-routes.middleware.response

Source

response.lisp (file)

Use List

common-lisp

Used By List

tiny-routes.middleware

Exported Definitions

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

5.10 tiny-routes.middleware

Source

middleware.lisp (file)

Use List
Used By List

tiny-routes


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

5.11 tiny-routes

Source

tiny-routes.lisp (file)

Nickname

tiny

Use List
Exported Definitions
Internal Definitions

prepare-route (macro)


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

6 Definitions

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


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

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Macros

Macro: define-any PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-delete PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-get PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-head PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-options PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-post PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-put PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-route REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)

Macro: define-routes NAME &body HANDLERS

Define a route handler from ROUTES

Package

tiny-routes

Source

tiny-routes.lisp (file)

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 (file)

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 (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Compiler macros

Compiler Macro: body-mapper-response &rest ARGS
Package

tiny-routes.response

Source

response.lisp (file)

Compiler Macro: body-response &rest ARGS
Package

tiny-routes.response

Source

response.lisp (file)

Compiler Macro: header-response &rest ARGS
Package

tiny-routes.response

Source

response.lisp (file)

Compiler Macro: headers-response &rest ARGS
Package

tiny-routes.response

Source

response.lisp (file)

Compiler Macro: headers-response-append &rest ARGS
Package

tiny-routes.response

Source

response.lisp (file)

Compiler Macro: status-response &rest ARGS
Package

tiny-routes.response

Source

response.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 Functions

Function: accepted &optional BODY

Return a response with status HTTP 202 Accepted and BODY.

Package

tiny-routes.response

Source

response.lisp (file)

Function: bad-request &optional BODY

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

Package

tiny-routes.response

Source

response.lisp (file)

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 (file)

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 (file)

Function: clack.io REQUEST &optional DEFAULT

Return the clack.io from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: clack.streaming REQUEST &optional DEFAULT

Return the the clack.streaming from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

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 (file)

Function: compose FUNCTION &rest OTHER-FUNCTIONS
Package

tiny-routes.util

Source

util.lisp (file)

Function: conflict &optional BODY

Return a response with status HTTP 409 Conflict and BODY.

Package

tiny-routes.response

Source

response.lisp (file)

Function: content-length REQUEST &optional DEFAULT

Return the content length from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: content-type REQUEST &optional DEFAULT

Return the content type from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

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 (file)

Function: forbidden &optional BODY

Return a response with status HTTP 403 Forbidden and BODY.

Package

tiny-routes.response

Source

response.lisp (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)

Function: make-response &key STATUS HEADERS BODY

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

Package

tiny-routes.response

Source

response.lisp (file)

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 (file)

Function: no-content ()

Return a response with status HTTP 204 No Content.

Package

tiny-routes.response

Source

response.lisp (file)

Function: not-acceptable &optional BODY

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

Package

tiny-routes.response

Source

response.lisp (file)

Function: not-found &optional BODY

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

Package

tiny-routes.response

Source

response.lisp (file)

Function: not-implemented &optional BODY

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

Package

tiny-routes.response

Source

response.lisp (file)

Function: ok &optional BODY

Return a response with status HTTP 200 OK and BODY.

Package

tiny-routes.response

Source

response.lisp (file)

Function: parse-query-parameters QUERY-STRING
Package

tiny-routes.middleware.query-parameters

Source

query-parameters.lisp (file)

Function: path-info REQUEST &optional DEFAULT

Return the path info from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

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 (file)

Function: query-string REQUEST &optional DEFAULT

Return the query string from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: raw-body REQUEST &optional DEFAULT

Return the raw body from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

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 (file)

Function: redirect LOCATION &optional STATUS

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

Package

tiny-routes.response

Source

response.lisp (file)

Function: remote-address REQUEST &optional DEFAULT

Return the remote address from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: remote-port REQUEST &optional DEFAULT

Return the remote port from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: request-append REQUEST KEY VALUE

Return a clone of REQUEST containing KEY and VALUE.

Package

tiny-routes.request

Source

request.lisp (file)

Function: request-body REQUEST &optional DEFAULT

Return the request body from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: request-get REQUEST KEY &optional DEFAULT

Return the value associated with KEY in REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

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 (file)

Function: request-headers REQUEST &optional DEFAULT

Return the headers from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: request-method REQUEST &optional DEFAULT

Return the request method from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: requestp OBJECT

Return t if OBJECT is a request.

Package

tiny-routes.request

Source

request.lisp (file)

Function: response-body RESPONSE

Return the RESPONSE body.

Package

tiny-routes.response

Source

response.lisp (file)

Function: response-header RESPONSE KEY &optional DEFAULT

Return the value of KEY from the headers of RESPONSE.

Package

tiny-routes.response

Source

response.lisp (file)

Function: response-headers RESPONSE

Return the headers of RESPONSE.

Package

tiny-routes.response

Source

response.lisp (file)

Function: response-status RESPONSE

Return the status of RESPONSE.

Package

tiny-routes.response

Source

response.lisp (file)

Function: responsep OBJECT

Return t if OBJECT is a response.

Package

tiny-routes.response

Source

response.lisp (file)

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 (file)

Function: script-name REQUEST &optional DEFAULT

Return the script name from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: server-name REQUEST &optional DEFAULT

Return the server name from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: server-port REQUEST &optional DEFAULT

Return the server port from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: server-protocol REQUEST &optional DEFAULT

Return the server protocol from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

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 (file)

Function: unauthorized &optional BODY

Return a response with status HTTP 401 Unauthorized and BODY.

Package

tiny-routes.response

Source

response.lisp (file)

Function: unprocessable-entity &optional BODY

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

Package

tiny-routes.response

Source

response.lisp (file)

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 (file)

Function: uri REQUEST &optional DEFAULT

Return the request URI from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: url-scheme REQUEST &optional DEFAULT

Return the URL scheme from REQUEST or DEFAULT.

Package

tiny-routes.request

Source

request.lisp (file)

Function: wrap-middleware-internal HANDLER

Wrap HANDLER such that post-match handlers are called.

Package

tiny-routes

Source

tiny-routes.lisp (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)

Function: wrap-response-body HANDLER BODY
Package

tiny-routes.middleware.response

Source

response.lisp (file)

Function: wrap-response-body-mapper HANDLER BODY-MAPPER
Package

tiny-routes.middleware.response

Source

response.lisp (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)

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 (file)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.4 Types

Type: request ()
Package

tiny-routes.request

Source

request.lisp (file)

Type: response ()
Package

tiny-routes.response

Source

response.lisp (file)


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

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [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 (file)

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

tiny-routes.response

Source

response.lisp (file)

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

tiny-routes.response

Source

response.lisp (file)

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

tiny-routes.response

Source

response.lisp (file)

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

tiny-routes.response

Source

response.lisp (file)

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

tiny-routes.response

Source

response.lisp (file)

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 (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Macros

Macro: prepare-route METHOD PATH-TEMPLATE REQ-BINDING &body BODY
Package

tiny-routes

Source

tiny-routes.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.3 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 (file)

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 (file)

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 (file)

Function: synchronous-response-p OBJECT

Return t if OBJECT is a synchronous response.

Package

tiny-routes.response

Source

response.lisp (file)

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 (file)


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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   M   T  
Index Entry  Section

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

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

M
Module, tiny-routes/middleware: The tiny-routes/middleware module

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

Jump to:   F   L   M   T  

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: Exported functions

B
bad-request: Exported functions
body-mapper-response: Exported compiler macros
body-mapper-response: Exported functions
body-response: Exported compiler macros
body-response: Exported functions

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

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

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

H
header-response: Exported compiler macros
header-response: Exported functions
headers-response: Exported compiler macros
headers-response: Exported functions
headers-response-append: Exported compiler macros
headers-response-append: Exported functions

I
internal-server-error: Exported functions

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

N
no-content: Exported functions
not-acceptable: Exported functions
not-found: Exported functions
not-implemented: Exported functions

O
ok: Exported functions

P
parse-query-parameters: Exported functions
path-info: Exported functions
payload-too-large: Exported functions
pipe: Exported macros
prepare-route: Internal macros

Q
query-string: Exported functions

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

S
script-name: Exported functions
server-name: Exported functions
server-port: Exported functions
server-protocol: Exported functions
status-response: Exported compiler macros
status-response: Exported functions
synchronous-response-p: Internal functions

T
too-many-requests: Internal functions

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

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

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

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

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*deprecated-function-style-warning-body-mapper-response-notified-p*: Internal special variables
*deprecated-function-style-warning-body-response-notified-p*: Internal special variables
*deprecated-function-style-warning-header-response-notified-p*: Internal special variables
*deprecated-function-style-warning-headers-response-append-notified-p*: Internal special variables
*deprecated-function-style-warning-headers-response-notified-p*: Internal special variables
*deprecated-function-style-warning-status-response-notified-p*: Internal special variables
*path-token-scanner*: Internal special variables

S
Special Variable, *deprecated-function-style-warning-body-mapper-response-notified-p*: Internal special variables
Special Variable, *deprecated-function-style-warning-body-response-notified-p*: Internal special variables
Special Variable, *deprecated-function-style-warning-header-response-notified-p*: Internal special variables
Special Variable, *deprecated-function-style-warning-headers-response-append-notified-p*: Internal special variables
Special Variable, *deprecated-function-style-warning-headers-response-notified-p*: Internal special variables
Special Variable, *deprecated-function-style-warning-status-response-notified-p*: Internal special variables
Special Variable, *path-token-scanner*: Internal special variables

Jump to:   *  
S  

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

A.4 Data types

Jump to:   P   R   S   T  
Index Entry  Section

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

R
request: Exported types
response: Exported types

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

T
tiny-routes: The tiny-routes system
tiny-routes: The tiny-routes package
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: Exported types
Type, response: Exported types

Jump to:   P   R   S   T