Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using the not-found-interceptor as a catchall
(ns support.service
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route]))
(defn about-page
[request]
{:status 200 :body (format "Clojure %s - served from %s"
(clojure-version)
(route/url-for ::about-page))})
(def home-page
{:name ::home-page
:enter (fn [context]
(assoc context :response {:status 200 :body "Hello world!"}))})
(def redirect-home
{:name ::redirect-home
:enter (fn [context]
(assoc context :response {:status 302 :body "Go home" :headers {"Location" "/"}}))})
(defn routes
[]
(route/expand-routes
`[[["/" {:get home-page}
["/api" {:post about-page
:get redirect-home}]]]]))
(def service {:env :prod
::http/routes routes
::http/not-found-interceptor redirect-home
::http/resource-path "/public"
::http/type :jetty
::http/port 8081})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.