Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Created November 12, 2017 08:24
Show Gist options
  • Save svetlyak40wt/cb478fa0d55e8cdf42d4826f76d99344 to your computer and use it in GitHub Desktop.
Save svetlyak40wt/cb478fa0d55e8cdf42d4826f76d99344 to your computer and use it in GitHub Desktop.
A short example of a HTTP api written in Common Lisp's framework Ningle.
;; Micro-framework for building API
(ql:quickload :ningle)
;; Now ningle is installed and we need to install a clack which is analog of WSGI
;; stack from Python
;; I've pressed C-c C-c to eval this form
(ql:quickload :clack)
;; To parse json:
(ql:quickload :jonathan)
(defvar *app* (make-instance 'ningle:<app>))
(setf (ningle:route *app* "/")
;; in case, if you need to parse or serialize JSON,
;; use Jonthan library.
(jonathan:to-json '(:foo 100500)))
(defvar *server* nil
"This variable will store currently running server instance.")
(defun start ()
(if *server*
(format t "Server already started")
(setf *server*
(clack:clackup *app*))))
(defun stop ()
(if *server*
(clack:stop *server*)
(format t "Server is not running")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment