The defrest Reference Manual

This is the defrest Reference Manual, version 1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 05:01:26 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 defrest

defrest: expose functions as REST webservices for ajax or other stuff

Author

Mathias Menzel-Nielsen <>

License

BSD

Version

1

Dependencies
  • hunchentoot (system).
  • cl-ppcre (system).
  • split-sequence (system).
  • quri (system).
Source

defrest.asd.

Child Component

defrest.lisp (file).


3 Files

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


3.1 Lisp


3.1.1 defrest/defrest.asd

Source

defrest.asd.

Parent Component

defrest (system).

ASDF Systems

defrest.

Packages

defrest-system.


3.1.2 defrest/defrest.lisp

Source

defrest.asd.

Parent Component

defrest (system).

Packages

defrest.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 defrest

Source

defrest.lisp.

Nickname

rest

Use List
  • cl-ppcre.
  • common-lisp.
  • hunchentoot.
  • split-sequence.
Public Interface
Internals

4.2 defrest-system

Source

defrest.asd.

Use List
  • asdf/interface.
  • common-lisp.

5 Definitions

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


5.1 Public Interface


5.1.1 Macros

Macro: defrest (pattern method varlist &body body)

Defines a new REST Method. It will listen to urls which match pattern,
have all template blocks replaced and binds variables to varlist.
Returns a dispatcher method, which can be put in the hunchentoot dispatcher
table AND creates an entry in the *rest-dispatcher-table* to be able to defrest
on toplevel.

Usage Example:

(defrest "/greet/{name:.+}" :GET (name)
(format nil "Hello ~a" name))

will create a Hello World Dispatcher which will greet GET /greet/Bonk with ’Hello Bonk’

Package

defrest.

Source

defrest.lisp.


5.1.2 Ordinary functions

Function: create-rest-table-dispatcher (&optional table)

builds a rest table dispatcher which can be added to the hunchentoot dispatchers to handle all defrest’ed functions

Package

defrest.

Source

defrest.lisp.

Function: undefrest (pattern)

Removes the rest service with the exact PATTERN from the rest-table-dispatcher

Package

defrest.

Source

defrest.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *rest-dispatcher-table*
Package

defrest.

Source

defrest.lisp.


5.2.2 Ordinary functions

Function: create-query-param-parser (binding &key mandatory pattern param default &allow-other-keys)

Compiles the query definition into a function that is to be called with the query parameters of the current request and returns the value of the query parameter

Package

defrest.

Source

defrest.lisp.

Function: create-rest-dispatcher (schema method query-param-schemes fun)

Creates a hunchentoot compatible dispatcher for a given url SCHEMA, request METHOD and QUERY-PARAM-Schemes which will call the FUN function on match and hands over a parameter map hashtable

Package

defrest.

Source

defrest.lisp.

Function: mark-template-splitpoints (schema)

Returns a list of all split positions to seperate templateblocks in SCHEMA.

Package

defrest.

Source

defrest.lisp.

Function: parse-schema (schema)

splits a schema into blocks representing it’s static parts and it’s placeholders.

Example 1:
’/test/{id:[a-z]+}’ => (’/test/’ (:KEY ’id’ :REGEXP ’[a-z]+’))

Example 2:
’/test/{id:[a-z]?[0-9]+}’ => (’/test/’ (:KEY ’id’ :REGEXP ’[a-z]?[0-9]+’))

Example 3:
’/album/{album:[a-z]+}/track/{track:[0-9]+}’ => (’/album/’ (:KEY ’album’ :REGEXP ’[a-z]+’) ’/track/’ (:KEY ’track’ :REGEXP ’[0-9]+’))

Example 4:
’/album/{album:[a-z]+}/track/{vol:[0-9]+}-{pos:[0-9]+}’ => (’/album/’ (:KEY ’album’ :REGEXP ’[a-z]+’) ’/track/’
(:KEY ’vol’ :REGEXP ’[0-9]+’) ’-’ (:KEY ’pos’ :REGEXP ’[0-9]+’))

Package

defrest.

Source

defrest.lisp.

Function: parse-uri (schema uri)

Parses URI against SCHEMA and returns a hashtable with all pathvariable bindings and as second value the query parameters

Package

defrest.

Source

defrest.lisp.

Function: parse-varlist (varlist)

Parses the varlist and returns a list of all bindings and a list of the bindings that are mapped to query parameters.

Package

defrest.

Source

defrest.lisp.

Function: schema->regexpurl (schema)

rips out the template blocks and replaces them with their regexp part. eg: {id:[0-9]+} becomes [0-9]+

Package

defrest.

Source

defrest.lisp.

Function: split-sequence-on-positions (seq poslist)

Splits SEQ on all positions listed in POSLIST

Package

defrest.

Source

defrest.lisp.

Function: split-template-blocks (uri)

splits an template uri to seperate the template placeholder blocks so that ’/bla/{var:.+}’ becomes (’/bla/’ ’{var:.+}’). best version

Package

defrest.

Source

defrest.lisp.


Appendix A Indexes


A.1 Concepts


A.3 Variables