From 3c83e74a84e57f8ee2a9e98c4045d9b3e7a937f5 Mon Sep 17 00:00:00 2001 From: Akira Tempaku <paku@skyizwhite.dev> Date: Tue, 1 Apr 2025 01:15:02 +0900 Subject: [PATCH] Set 404 status to not-found response --- src/router.lisp | 3 +++ tests/routes/not-found.lisp | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/router.lisp b/src/router.lisp index de26076..6a2b150 100644 --- a/src/router.lisp +++ b/src/router.lisp @@ -7,6 +7,8 @@ #:regex-replace #:regex-replace-all) (:import-from #:ningle) + (:import-from #:lack/response + #:response-status) (:import-from #:trivial-system-loader #:load-system) (:export #:pathname->path @@ -60,6 +62,7 @@ (if (string= uri "/not-found") (let ((handler (find-symbol "HANDLE-NOT-FOUND" pkg))) (defmethod ningle:not-found ((app ningle:app)) + (setf (response-status ningle:*response*) 404) (funcall handler)))) (loop :for method :in *http-request-methods* diff --git a/tests/routes/not-found.lisp b/tests/routes/not-found.lisp index 5392fd8..a1b259d 100644 --- a/tests/routes/not-found.lisp +++ b/tests/routes/not-found.lisp @@ -1,11 +1,7 @@ (defpackage #:ningle-fbr-test/routes/not-found (:use #:cl) - (:import-from #:lack/response) - (:import-from #:ningle) (:export #:handle-not-found)) (in-package #:ningle-fbr-test/routes/not-found) (defun handle-not-found () - (setf (lack/response:response-status ningle:*response*) - 404) "Not Found")