Created
May 10, 2011 18:04
-
-
Save skuro/965008 to your computer and use it in GitHub Desktop.
Clojure WebScript sample
This file contains hidden or 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 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.) |
This file contains hidden or 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
<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> |
This file contains hidden or 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
<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