Skip to content

Instantly share code, notes, and snippets.

@skuro
Created May 10, 2011 18:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skuro/965008 to your computer and use it in GitHub Desktop.
Save skuro/965008 to your computer and use it in GitHub Desktop.
Clojure WebScript sample
;; ns forms are currently useless
;; Import the protocol
(import '[spring.surf.webscript WebScript])
;; Let's make use of some utility functions
(require '[spring.surf.webscript :as w])
;; Concrete WebScript implementation
(deftype SampleWebScript
[]
WebScript
(run [this in out model]
;; fetch the args and provide the map of values for the view, in a handy way
(w/return model {:cljResult (str "Hello, " (:name (w/args model)))})))
;; Return an instance of our WebScript implementation
(SampleWebScript.)
<webscript>
<shortname>Sample Clojure WebScript</shortname>
<description>Demonstrate how to use Clojure to implement a WebScript controller!</description>
<url>/clj/sample?greet={name}</url>
<authentication>none</authentication>
</webscript>
<html>
<body>
<p>clojure says ${cljResult}</p>
</body>
</htlm>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment