Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the ningle Reference Manual, version 0.3.0, generated automatically by Declt version 3.0 "Montgomery Scott" on Tue Dec 22 14:30:47 2020 GMT+0.
• Introduction | What ningle 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 |
"ningle" is a lightweight web application framework for Common Lisp.
(defvar *app* (make-instance 'ningle:app))
(setf (ningle:route *app* "/")
"Welcome to ningle!")
(setf (ningle:route *app* "/login" :method :POST)
#'(lambda (params)
(if (authorize (cdr (assoc "username" params :test #'string=))
(cdr (assoc "password" params :test #'string=)))
"Authorized!"
"Failed...Try again.")))
(clack:clackup *app*)
Now you can access to http://localhost:5000/ and then ningle should show you "Welcome to ningle!".
(ql:quickload :ningle)
ningle is a fork project of Caveman. ningle doesn't require you to generate a project skeleton.
As this is a thin framework, you need to have subtle knowledge about Clack. It is a server interface ningle bases on.
ningle has the Sinatra-like routing system.
;; GET request (default)
(setf (ningle:route *app* "/" :method :GET) ...)
;; POST request
(setf (ningle:route *app* "/" :method :POST) ...)
;; PUT request
(setf (ningle:route *app* "/" :method :PUT) ...)
;; DELETE request
(setf (ningle:route *app* "/" :method :DELETE) ...)
;; OPTIONS request
(setf (ningle:route *app* "/" :method :OPTIONS) ...)
Route pattern may contain "keyword" to put the value into the argument.
(setf (ningle:route *app* "/hello/:name")
#'(lambda (params)
(format nil "Hello, ~A" (cdr (assoc :name params)))))
The above controller will be invoked when you access to "/hello/Eitaro" or "/hello/Tomohiro", and then (cdr (assoc :name params))
will be "Eitaro" and "Tomohiro".
Route patterns may also contain "wildcard" parameters. They are accessible by (assoc :splat params)
.
(setf (ningle:route *app* "/say/*/to/*")
#'(lambda (params)
; matches /say/hello/to/world
(cdr (assoc :splat params)) ;=> ("hello" "world")
))
(setf (ningle:route *app* "/download/*.*")
#'(lambda (params)
; matches /download/path/to/file.xml
(cdr (assoc :splat params)) ;=> ("path/to/file" "xml")
))
Route matching with Regular Expressions:
(setf (ningle:route *app* "/hello/([\\w]+)" :regexp t)
#'(lambda (params)
(format nil "Hello, ~A!" (first (cdr (assoc :captures params))))))
Routes may include a variety of matching conditions, such as the Accept:
(setf (ningle:route *app* "/" :accept '("text/html" "text/xml"))
#'(lambda (params)
(declare (ignore params))
"<html><body>Hello, World!</body></html>"))
(setf (ningle:route *app* "/" :accept "text/plain")
#'(lambda (params)
(declare (ignore params))
"Hello, World!"))
You can easily define your own conditions:
(setf (ningle:requirement *app* :probability)
#'(lambda (value)
(<= (random 100) value)))
(setf (ningle:route *app* "/win_a_car" :probability 10)
#'(lambda (params)
(declare (ignore params))
"You won!"))
(setf (ningle:route *app* "/win_a_car")
#'(lambda (params)
(declare (ignore params))
"Sorry, you lost."))
ningle provides two special variables named *request*
and *response*
. They will be bound to an instance Lack.Request and Lack.Response for each request.
For example, by using them, you can change the response status code, Content-Type or something like that in each controllers.
(setf (lack.response:response-headers *response*)
(append (lack.response:response-headers *response*)
(list :content-type "application/json")))
(setf (lack.response:response-headers *response*)
(append (lack.response:response-headers *response*)
(list :access-control-allow-origin "*")))
(setf (lack.response:response-status *response*) 201)
ningle provides an useful function named context
. It is an accessor to an internal hash table.
(setf (context :database)
(dbi:connect :mysql
:database-name "test-db"
:username "nobody"
:password "nobody"))
(context :database)
;;=> #<DBD.MYSQL:<DBD-MYSQL-CONNECTION> #x3020013D1C6D>
ningle doesn't provide Session system in the core, but recommends to use Lack.Middleware.Session with Lack.Builder.
(import 'lack.builder:builder)
(clack:clackup
(builder
:session
*app*))
Of course, you can use other Lack Middlewares with ningle.
Copyright (c) 2012-2014 Eitaro Fukamachi (e.arrows@gmail.com)
Licensed under the LLGPL License.
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The ningle system | ||
• The ningle/main system | ||
• The ningle/app system | ||
• The ningle/route system | ||
• The ningle/context system |
Next: The ningle/main system, Previous: Systems, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
Super micro framework for Common Lisp.
0.3.0
ningle.asd (file)
Next: The ningle/app system, Previous: The ningle system, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
ningle.asd (file)
lisp.lisp (file)
Next: The ningle/route system, Previous: The ningle/main system, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
ningle.asd (file)
lisp.lisp (file)
Next: The ningle/context system, Previous: The ningle/app system, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
myway
ningle.asd (file)
lisp.lisp (file)
Previous: The ningle/route system, Up: Systems [Contents][Index]
Eitaro Fukamachi
LLGPL
ningle.asd (file)
lisp.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
• The ningle.asd file | ||
• The ningle/main/lisp.lisp file | ||
• The ningle/app/lisp.lisp file | ||
• The ningle/route/lisp.lisp file | ||
• The ningle/context/lisp.lisp file |
Next: The ningle/main/lisp․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
ningle.asd
Next: The ningle/app/lisp․lisp file, Previous: The ningle․asd file, Up: Lisp files [Contents][Index]
ningle/main (system)
main.lisp
Next: The ningle/route/lisp․lisp file, Previous: The ningle/main/lisp․lisp file, Up: Lisp files [Contents][Index]
ningle/app (system)
app.lisp
Next: The ningle/context/lisp․lisp file, Previous: The ningle/app/lisp․lisp file, Up: Lisp files [Contents][Index]
ningle/route (system)
route.lisp
Previous: The ningle/route/lisp․lisp file, Up: Lisp files [Contents][Index]
ningle/context (system)
context.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The ningle package | ||
• The ningle/app package | ||
• The ningle/route package | ||
• The ningle/context package |
Next: The ningle/app package, Previous: Packages, Up: Packages [Contents][Index]
lisp.lisp (file)
ningle/main
Next: The ningle/route package, Previous: The ningle package, Up: Packages [Contents][Index]
lisp.lisp (file)
ningle.app
common-lisp
Next: The ningle/context package, Previous: The ningle/app package, Up: Packages [Contents][Index]
lisp.lisp (file)
ningle.route
common-lisp
Previous: The ningle/route package, Up: Packages [Contents][Index]
lisp.lisp (file)
ningle.context
common-lisp
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 functions | ||
• Exported generic functions | ||
• Exported classes |
Next: Exported macros, Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Special variable to store Ningle Context, a hash table.
Don’t set to this variable directly. This is designed to be bound in lexical let.
lisp.lisp (file)
Special variable to store Ningle Request, a instance of ‘<request>’ in Ningle.Request package. Don’t set to this variable directly. This is designed to be bound in lexical let.
lisp.lisp (file)
Special variable to store Ningle Response, a instance of ‘<response>’ in Ningle.Response package. Don’t set to this variable directly. This is designed to be bound in lexical let.
lisp.lisp (file)
Special variable to store session.
Don’t set to this variable directly. This is designed to be bound in lexical let.
lisp.lisp (file)
Next: Exported functions, Previous: Exported special variables, Up: Exported definitions [Contents][Index]
lisp.lisp (file)
Next: Exported generic functions, Previous: Exported macros, Up: Exported definitions [Contents][Index]
lisp.lisp (file)
Access to current context. If key is specified, return the value in current context.
If not, just return a current context.
Example:
(context)
;=> #<HASH-TABLE :TEST EQL size 0/60 #x3020025FF5FD>
(context :request)
;=> #<CAVEMAN.REQUEST:<REQUEST> #x3020024FCCFD>
lisp.lisp (file)
(setf context) (function)
Create a new Context.
lisp.lisp (file)
lisp.lisp (file)
Next: Exported classes, Previous: Exported functions, Up: Exported definitions [Contents][Index]
Make a request object. See ningle.app for the default behavior.
Make a response object. See ningle.app for the default behavior.
An action when no routing rules are found.
lisp.lisp (file)
lisp.lisp (file)
lisp.lisp (file)
Previous: Exported generic functions, Up: Exported definitions [Contents][Index]
Base class for Ningle Application. All Ningle Application must inherit this class.
lisp.lisp (file)
lack-component (class)
(myway.mapper:make-mapper)
mapper (generic function)
(setf mapper) (generic function)
hash-table
(ningle/app::default-requirements-map)
app-requirements (generic function)
(setf app-requirements) (generic function)
Base class for Ningle Application. All Ningle Application must inherit this class.
lisp.lisp (file)
lack-component (class)
(myway.mapper:make-mapper)
mapper (generic function)
(setf mapper) (generic function)
hash-table
(ningle/app::default-requirements-map)
app-requirements (generic function)
(setf app-requirements) (generic function)
lisp.lisp (file)
route (class)
:requirements
(quote nil)
route-requirements (generic function)
(setf route-requirements) (generic function)
:compiled-requirements
route-compiled-requirements (generic function)
(setf route-compiled-requirements) (generic function)
:controller
route-controller (generic function)
(setf route-controller) (generic function)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal macros | ||
• Internal functions | ||
• Internal generic functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
lisp.lisp (file)
Next: Internal generic functions, Previous: Internal macros, Up: Internal definitions [Contents][Index]
lisp.lisp (file)
lisp.lisp (file)
Previous: Internal functions, Up: Internal definitions [Contents][Index]
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 N |
---|
Jump to: | F L N |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | (
A C D F G M N P R W |
---|
Jump to: | (
A C D F G M N P R W |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
C M R S |
---|
Jump to: | *
C M R S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | <
A C N P S |
---|
Jump to: | <
A C N P S |
---|