Created
April 8, 2013 20:05
-
-
Save ddeaguiar/5340019 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns foo.service | |
(:require [io.pedestal.service.http :as bootstrap] | |
[io.pedestal.service.http.route :as route] | |
[io.pedestal.service.http.body-params :as body-params] | |
[io.pedestal.service.http.route.definition :refer [defroutes]] | |
[ring.util.response :as ring-resp])) | |
(defn about-page | |
[request] | |
(ring-resp/response (format "Clojure %s" (clojure-version)))) | |
(defn home-page | |
[request] | |
(ring-resp/response "Hello World!")) | |
(defroutes routes | |
[[["/" {:get home-page} | |
;; Set default interceptors for /about and any other paths under / | |
^:interceptors [(body-params/body-params)] | |
["/about" {:get about-page}]]]]) | |
;; You can use this fn or a per-request fn via io.pedestal.service.http.route/url-for | |
(def url-for (route/url-for-routes routes)) | |
;; Consumed by foo.server/create-server | |
(def service {:env :prod | |
;; You can bring your own non-default interceptors. Make | |
;; sure you include routing and set it up right for | |
;; dev-mode. If you do, many other keys for configuring | |
;; default interceptors will be ignored. | |
;; :bootstrap/interceptors [] | |
::bootstrap/routes routes | |
;; Uncomment next line to enable CORS support, add | |
;; string(s) specifying scheme, host and port for | |
;; allowed source(s): | |
;; | |
;; "http://localhost:8080" | |
;; | |
;;::boostrap/allowed-origins ["scheme://host:port"] | |
;; Root for resource interceptor that is available by default. | |
::bootstrap/resource-path "/public" | |
;; Either :jetty or :tomcat (see comments in project.clj | |
;; to enable Tomcat) | |
;;::bootstrap/host "localhost" | |
::bootstrap/type :jetty | |
::bootstrap/port 8080}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment