Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the simple-routes Reference Manual, version 0.3, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 15:02:46 2020 GMT+0.
• Introduction | What simple-routes is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
A simple Common Lisp RESTful routing facility on top of Hunchentoot.
This library provides a method for simple, centralized http routing on top of Hunchentoot. When you use this library with hunchentoot it takes priority over the default hunchentoot routing system but does not replace it. If simple-routes does not match a handler to a given request, it will fall back to hunchentoot's other url routing methods (easy-handler, then the default static file service).
I wrote this library because the current routing methods I found were either too complicated for my needs (Restas) or too unstructured for a RESTful api (Hunchentoot easy-handler).
simple-routes searches through *routeslist* for every incoming request to try to find a matching handler for the incoming url.
(setf simple-routes:*routeslist*
(compile-routes
;;html content uris
(:GET "" 'home-handler)
(:GET "/people" 'people-handler)
(:GET "/people/:first/:last" 'get-person-handler)
(:PUT "/people/:first/:last/:description" 'put-person-handler)
))
This will register the listed relative urls with whatever functions are defined with names matching those specified in the rightmost column. It will automatically forward the url segments which are keywords (start with a ":") as arguments to the handlers. Here are corresponding function signatures for the url-handler functions.
(defun home-handler () ())
(defun people-handler () ())
(defun get-person-handler (first last) ())
(defun put-person-handler (first last description) ())
See simpleroutes-demo for a self-contained example web app using simple-routes! To run the demo:
* (load "simpleroutes-build.asd")
* (asdf:operate 'asdf:load-op 'simpleroutes-demo)
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The simple-routes system |
Currell Berry
2 clause BSD
Facility for straightforward http routing on top of Hunchentoot.
0.3
simple-routes.asd (file)
simple-routes.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The simple-routes.asd file | ||
• The simple-routes/simple-routes.lisp file |
Next: The simple-routes/simple-routes․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
simple-routes.asd
simple-routes (system)
Previous: The simple-routes․asd file, Up: Lisp files [Contents][Index]
simple-routes (system)
simple-routes.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The simpleroutes-asd package | ||
• The simple-routes package |
Next: The simple-routes package, Previous: Packages, Up: Packages [Contents][Index]
simple-routes.asd
Previous: The simpleroutes-asd package, Up: Packages [Contents][Index]
simple-routes.lisp (file)
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported special variables | ||
• Exported macros | ||
• Exported classes |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
should contain routes compiled with routespec-compile or manually entered in compiled form incoming requests are matched up against each item in *routeslist* successively, until (and if) a matching routespec is found.
simple-routes.lisp (file)
Next: Exported classes, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
this is intended to be used to access get and post parameters. example usage
(bind-alist-values (first second) (hunchentoot:get-parameters*)
(list first second))
simple-routes.lisp (file)
simple-routes.lisp (file)
simple-routes.lisp (file)
Previous: Exported macros, Up: Exported definitions [Contents][Index]
This first tries to route requests using simple-router, then falls back to hunchentoot’s default easy-acceptor.
simple-routes.lisp (file)
easy-acceptor (class)
simpleroutes-ssl-acceptor (class)
acceptor-dispatch-request (method)
This is an acceptor that mixes the simpleroutes acceptor with SSL connections.
simple-routes.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal functions |
Previous: Internal definitions, Up: Internal definitions [Contents][Index]
simple-routes.lisp (file)
simple-routes.lisp (file)
removes the last item in sequence IF THE SEQUENCE HAS A LAST ITEM
simple-routes.lisp (file)
httpmethod can be one of :GET :HEAD :POST :PUT :DELETE or :ALL
urldef is a url definition string sharing *basic* syntax with Ruby on Rails
fntocall is the function to call in case the this is found to be a match for the request
this macro returns a list which is meant to be processed by cl-simple routehandler
example call:
=>(rtreg :GET “/home/next/:number” #’nxthandler) returns
(:GET "^/home/next/([^/]*)$" (NUMBER)
#<CLOSURE (LAMBDA # :IN MACRO-FUNCTION) {1000F213DB}>)
the output of this macro can in turn be processed by simple-processor
simple-routes.lisp (file)
takes in a request uri and type (:GET, :POST, etc...) and loops through all
compiled routes in *routeslist*. If it finds a route that matches
,it returns the associated handler and returns true. otherwise returns false
simple-routes.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | F L S |
---|
Jump to: | F L S |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | B C D F I L M R S |
---|
Jump to: | B C D F I L M R S |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
S |
---|
Index Entry | Section | ||
---|---|---|---|
| |||
* | |||
*routeslist* : | Exported special variables | ||
| |||
S | |||
Special Variable, *routeslist* : | Exported special variables | ||
|
Jump to: | *
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P S |
---|
Jump to: | C P S |
---|