1
0
Fork 0

- [gemini] added better names for status code of a gemini response (e.g. '+20+' -> '+success+').

This commit is contained in:
cage 2022-12-28 13:57:15 +01:00
parent fb4be7bb9f
commit f8bf6aa360
2 changed files with 27 additions and 5 deletions

View File

@ -33,11 +33,15 @@
(code b)))) (code b))))
(defmacro gen-status-constant (value description) (defmacro gen-status-constant (value description)
`(define-constant ,(format-fn-symbol t "+~a+" value) (with-gensyms (error-object)
(make-instance 'response-status-code (let* ((clean-error-name (cl-ppcre:regex-replace-all "[-,.]" description ""))
(splitted-error-name (cl-ppcre:split "\\s+" clean-error-name))
(error-name-verbose (text-utils:join-with-strings splitted-error-name "-")))
`(let ((,error-object (make-instance 'response-status-code
:code ,value :code ,value
:description ,description) :description ,description)))
:test #'response=)) (define-constant ,(format-fn-symbol t "+~a+" value) ,error-object :test #'response=)
(define-constant ,(format-fn-symbol t "+~a+" error-name-verbose) ,error-object :test #'response=)))))
(gen-status-constant 10 "Input") (gen-status-constant 10 "Input")

View File

@ -126,6 +126,24 @@
:description :description
:find-code-description :find-code-description
:find-code-class :find-code-class
:+input+
:+sensitive-input+
:+success+
:+redirect-temporary+
:+redirect-permanent+
:+temporary-failure+
:+server-unavailable+
:+cgi-error+
:+proxy-error+
:+slow-down+
:+permanent-failure+
:+not-found+
:+gone+
:+proxy-request-refused+
:+bad-request+
:+client-certificate-required+
:+certificate-not-authorised+
:+certificate-not-valid+
:mime-gemini-p :mime-gemini-p
:mime-text-stream :mime-text-stream
:gemini-protocol-error :gemini-protocol-error