diff options
| author | ckonstanski <ckonstanski@pippiandcarlos.com> | 2018-01-20 22:07:54 -0700 |
|---|---|---|
| committer | ckonstanski <ckonstanski@pippiandcarlos.com> | 2018-01-20 22:07:54 -0700 |
| commit | c2f77f4296c6b13eeb86067a772192b70577bca6 (patch) | |
| tree | 8437af60a559b7ed206fe4b256b4ea583292b9f1 /service/rest-service.lisp | |
initial commit
Diffstat (limited to 'service/rest-service.lisp')
| -rw-r--r-- | service/rest-service.lisp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/service/rest-service.lisp b/service/rest-service.lisp new file mode 100644 index 0000000..693463f --- /dev/null +++ b/service/rest-service.lisp @@ -0,0 +1,33 @@ +;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*- +(declaim (optimize (speed 0) (safety 3) (debug 3))) + +(in-package #:ldapadmin) + +;; ========================================================================== ;; + +(defclass rest-service (base-service) + ((location :initarg :location + :initform nil + :accessor location) + (location-p :initarg :location-p + :initform t + :accessor location-p) + (errormsg :initarg :errormsg + :initform nil + :accessor errormsg) + (message :initarg :message + :initform nil + :accessor message)) + (:documentation "")) + +(defmethod initialize-instance :after ((rest-service rest-service) &key) + (when (and (location-p rest-service) (null (location rest-service))) + (setf (location rest-service) (type-to-path rest-service)) + (setf (session-value :location) (location rest-service)))) + +(defun location-json () + (let ((location (if (session-value :location) (session-value :location) "/home"))) + (format nil "{\"location\":\"~a\"}" location))) + +(defun type-to-path (rest-type) + (concatenate 'string "/" (ppcre:regex-replace "-" (string-downcase (type-of rest-type)) "/"))) |
