Check if survey id is valid
This commit is contained in:
parent
f1bedd6c7c
commit
799d351917
2 changed files with 6 additions and 3 deletions
|
@ -5,7 +5,8 @@
|
|||
(let ((parts (split-uri uri)))
|
||||
(and (= (length parts) 3)
|
||||
(string= (first parts) "survey")
|
||||
(every #'digit-char-p (second parts)))))
|
||||
(every #'digit-char-p (second parts))
|
||||
(valid-survey-id-p (parse-integer (second parts))))))
|
||||
|
||||
(defun questionnaire-uri (request)
|
||||
(questionnaire-uri-p (request-uri request)))
|
||||
|
|
|
@ -2,17 +2,19 @@
|
|||
|
||||
(defun survey-uri-p (uri)
|
||||
"Check if the request URI matches the pattern '/survey/<numeric>'"
|
||||
(check-type uri string)
|
||||
(let ((parts (split-uri uri)))
|
||||
(and (= (length parts) 2)
|
||||
(string= (first parts) "survey")
|
||||
(every #'digit-char-p (second parts)))))
|
||||
(every #'digit-char-p (second parts))
|
||||
(valid-survey-id-p (parse-integer (second parts))))))
|
||||
|
||||
(defun survey-uri (request)
|
||||
(let ((uri (request-uri request)))
|
||||
(survey-uri-p uri)))
|
||||
|
||||
(define-easy-handler (survey :uri #'survey-uri) ()
|
||||
(let* ((id (subseq (request-uri*) (length "/survey/")))
|
||||
(let* ((id (second (split-uri (request-uri*))))
|
||||
(survey (assoc (parse-integer id)
|
||||
(load-response (make-surveys-db-path)))))
|
||||
(ml-survey/views:survey survey)))
|
||||
|
|
Loading…
Add table
Reference in a new issue