Skip to content

Instantly share code, notes, and snippets.

@tcoupland
tcoupland / gist:2518012
Created April 28, 2012 11:05
Simple compojure handler with logging middleware stacktrace
before
Exception: java.lang.NullPointerException: null
core.clj:10 compojur-learning.core/logging[fn]
Var.java:401 clojure.lang.Var.invoke
@tcoupland
tcoupland / compojureHandler2.clj
Created April 28, 2012 11:02
Simple compojure handler with logging middleware
(ns compojur-learning.core
(:use compojure.core))
(defroutes handler
(GET "/" [] (println "middle") {:status 200}))
(defn logging [chain] (fn [req] (
(println "before")
(chain req)
(println "after"))))
@tcoupland
tcoupland / compujureHandler1.clj
Created April 28, 2012 10:53
Simple compojure handler
(ns compojur-learning.core
(:use compojure.core))
(defroutes handler
(GET "/" [] (println "middle") {:status 200}))
(def app (-> handler))
public class NeedVistorPattern {
public static void main(String[] args){
SpaceShip ship = new BigSpaceShip();
SpaceShipLauncher launcher = new SpaceShipLauncher();
launcher.launch(ship);
}
private static class SpaceShipLauncher{
@tcoupland
tcoupland / WhoNeedsVisitor.groovy
Created November 11, 2010 21:40
WhoNeedsVisitor
SpaceShip ship = new BigSpaceShip();
LauncherSystem launcher = new LauncherSystem();
launcher.launch(ship);
class LauncherSystem{
public void launch(SpaceShip ship){
Launcher launcher = new Launcher();
launcher.launch(ship);
}