From 7cb66ec41337b691075eae074b73025d65f1b843 Mon Sep 17 00:00:00 2001 From: Tommi Reiman Date: Thu, 9 Nov 2017 15:59:24 +0000 Subject: [PATCH] Documenting Ring + 404 (Fixes #43) --- doc/ring/ring.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/ring/ring.md b/doc/ring/ring.md index 0ac7aea7..4c0b6cad 100644 --- a/doc/ring/ring.md +++ b/doc/ring/ring.md @@ -112,6 +112,24 @@ Middleware is applied correctly: ; {:status 200, :body [:api :admin :db :delete :handler]} ``` +# Not found + +If no routes match, `nil` is returned, which is not understood by Ring. + +Enabling custom error messages: + +```clj +(def app + (some-fn + (ring/ring-handler + (ring/router + ["/ping" handler])) + (constantly {:status 404}))) + +(app {:uri "/invalid"}) +; {:status 404} +``` + # Async Ring All built-in middleware provide both 2 and 3-arity and are compiled for both Clojure & ClojureScript, so they work with [Async Ring](https://www.booleanknot.com/blog/2016/07/15/asynchronous-ring.html) and [Node.js](https://nodejs.org) too.