https://github.com/Rudolph-Miller/integral-rest.git
git clone 'https://github.com/Rudolph-Miller/integral-rest.git'
(ql:quickload :integral-rest)
(defclass user ()
((id :initarg :id
:primary-key t)
(name :initarg :name))
(:metaclass <dao-table-class>))
(set-rest-app)
(clack:clackup *rest-app*)
(ql:quickload :integral-rest)
(defclass user ()
((id :initarg :id
:primary-key t
:accessor user-id)
(name :initarg :name
:accessor user-name))
(:metaclass integral:<dao-table-class>))
(set-rest-app)
;; This sets REST API app to *rest-app*.
(defvar *my-rest-app* (set-rest-app))
;; (set-rest-app) also returns REST API app.
(set-rest-app (list (find-class 'user)))
;; (set-rest-app) can take list of class. (optional)
"/api/users" :GET
"/api/users" :POST
"/api/users/:id" :GET
"/api/users/:id" :PUT
"/api/users/:id" :DELETE
(defclass user ()
((id :initarg :id
:primary-key t
:accessor user-id)
(name :initarg :name
:accessor user-name))
(:metaclass integral:<dao-table-class>))
(set-rest-app)
(clack:clackup *rest-app*)
;; => Listening on localhost:5000.
(create-dao 'user :name "Rudolph")
;; => #<USER id: 1>
(dex:get "http://localhost:5000/api/users")
;; => "[{\"id\":1,\"name\":\"Rudolph\"}]"
(dex:get "http://localhost:5000/api/users/1")
;; => "{\"id\":1,\"name\":\"Rudolph\"}"
(dex:post "http://localhost:5000/api/users" :contest '(("name" . "Miller")))
;; => "{\"id\":2,\"name\":\"Miller\"}"
(find-dao 'user 2)
;; => #<USER id: 2 name: "Miller">
(dex:put "http://localhost:5000/api/users/2" :contest '(("name" . "Tom")))
;; => "{\"id\":2,\"name\":\"Tom\"}"
(find-dao 'user 2)
;; => #<USER id: 2 name: "Tom">
(dex:delete "http://localhost:5000/api/users/2")
;; => "{\"id\":2,\"name\":\"Tom\"}"
(find-dao 'user 2)
;; => NIL
(defclass user ()
((id :initarg :id
:primary-key t
:accessor user-id)
(name :initarg :name
:accessor user-name))
(:metaclass integral:<dao-table-class>))
(set-rest-app)
(routing-rules *rest-app*)
;; => '(("/api/users" :GET) ("/api/users" :POST) ("/api/users/:id" :GET)
;; ("/api/users/:id" :PUT) ("/api/users/:id" :DELETE))
Copyright (c) 2015 Rudolph-Miller
Licensed under the MIT License.