Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,31 +48,32 @@ something. Clothesline is a way of finding out.

Using the `defsimplehandler` in `clothesline.service.helpers` we can
quickly make a simple hello-world service:

(ns example1
(:use clothesline.core
[clothesline.service.helpers :only [defsimplehandler]])

;; A default handler that only cares about content-types.
;;
;; This not only defines a type, but actually instantiates
;; example1-server. defsimplehandler is not meant for anything
;; but the simplest use.
(defsimplehandler example1-simple
"text/plain" (fn [request graphdata] "Hello World."))

;; Request is the ring request, passed through.
;; graphdata is the accumulated data about the response.
(defsimplehandler example1-params
"text/plain" (fn [request graphdata]
(str "Your params: " (:params request))))
;; A traditional clout routing table. Note the colon-params in the
;; service are provided and placed in
(def routes {"/" example1-simple, "/:gratis" example1-params})

;; This is our server instance:
(defonce *server*
(produce-server routes {:port 9999 :join? false}))
```clojure
(ns example1
(:use clothesline.core
[clothesline.service.helpers :only [defsimplehandler]])

;; A default handler that only cares about content-types.
;;
;; This not only defines a type, but actually instantiates
;; example1-server. defsimplehandler is not meant for anything
;; but the simplest use.
(defsimplehandler example1-simple
"text/plain" (fn [request graphdata] "Hello World."))

;; Request is the ring request, passed through.
;; graphdata is the accumulated data about the response.
(defsimplehandler example1-params
"text/plain" (fn [request graphdata]
(str "Your params: " (:params request))))
;; A traditional clout routing table. Note the colon-params in the
;; service are provided and placed in
(def routes {"/" example1-simple, "/:gratis" example1-params})

;; This is our server instance:
(defonce *server*
(produce-server routes {:port 9999 :join? false}))
```

`defsimplehandler` is actually a very simple macro. It expands our form
to the relatively simple handler form that overrides
Expand Down