Skip to content

Commit

Permalink
Show name of process in body of 404 response
Browse files Browse the repository at this point in the history
  • Loading branch information
mdemare committed Sep 18, 2024
1 parent 336b240 commit 4d90dd5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/nl/surf/eduhub_rio_mapper/endpoints/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@
(wrap-json-response)
(wrap-trace-context)
(defaults/wrap-defaults defaults/api-defaults)
(wrap-server-status))))
(wrap-server-status)
(app-server/wrap-not-found-handler "serve-api says 404\n"))))

(defn shutdown-handler []
;; All subsequent requests will get a 503 error
Expand Down
10 changes: 9 additions & 1 deletion src/nl/surf/eduhub_rio_mapper/endpoints/app_server.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@
;; <https://www.gnu.org/licenses/>.

(ns nl.surf.eduhub-rio-mapper.endpoints.app-server
(:require [ring.adapter.jetty :as jetty])
(:require [nl.jomco.http-status-codes :as http-status]
[ring.adapter.jetty :as jetty])
(:import [org.eclipse.jetty.server HttpConnectionFactory]))

(defn wrap-not-found-handler [app msg]
(fn [req]
(let [response (app req)]
(if (= http-status/not-found (:status response))
(assoc response :body (str msg (:body response)))
response))))

(defn run-jetty [app host port]
(jetty/run-jetty app
{:host host
Expand Down
3 changes: 2 additions & 1 deletion src/nl/surf/eduhub_rio_mapper/endpoints/worker_api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
(wrap-json-response)
(wrap-logging)
(wrap-trace-context)
(defaults/wrap-defaults defaults/api-defaults)))
(defaults/wrap-defaults defaults/api-defaults)
(app-server/wrap-not-found-handler "worker-api says 404\n")))

(defn serve-api
[{{:keys [^Integer port host]} :worker-api-config :as config}]
Expand Down

0 comments on commit 4d90dd5

Please sign in to comment.