blob: 9f9f3d78f9041f058b1daf80f567c054ed438763 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(declaim (optimize (speed 0) (safety 3) (debug 3)))
(in-package :bogenherr)
(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 (location-p rest-service)
(when (null (location rest-service))
(setf (location rest-service) (type-to-path rest-service)))))
(defun location-json (&optional (location "/home"))
(format nil "{\"location\":\"~a\"}" location))
(defun type-to-path (rest-type)
(concatenate 'string "/" (ppcre:regex-replace "-service$" (string-downcase (type-of rest-type)) "")))
(defmethod sanitize-rest-json ((rest-service rest-service))
(loop for slot in (intersection '(org-ckons-session::*session-key *table *where-expression pwd)
(org-ckons-core::map-slot-names rest-service))
do (setf (slot-value rest-service slot) nil)))
(define-endpoint ("/location" :method :post) (&post (location :parameter-type 'string)) location-json location)
|