Skip to content

Instantly share code, notes, and snippets.

#include <stdio.h>
inline int max(int a, int b) {
return a > b ? a : b;
}
int main(int argc, char** argv) {
printf("Max of 3 and 5: %d\n", max(3, 5));
return 0;
}
(ns comp3.core
(:use compojure.core)
(:require [compojure.route :as route]
[ring.adapter.jetty :as jetty]))
(defn simple-logging-middleware [app]
(fn [req]
(println req)
(app req)))
;; The middleware takes 'app' as its parameter. In this
;; context app is going to be either another middleware
;; or the route handler.
;;
;; The return value is a new function that does the
;; processing you need and continues the middleware
;; chain.
(defn my-middleware [app]
(fn [request]
;; This is where you'd do any processing on the request
(ns comp2.core
(:use compojure.core)
(:require [compojure.route :as route]
[ring.middleware.session :as session]
[ring.adapter.jetty :as jetty]))
(defn set-session-var [session]
(if (:my-var session)
{:body "Session variable already set"}
{:body "Nothing in session, setting the var"
(ns comp1.core
(:use compojure.core)
(:require [compojure.route :as route]
[ring.adapter.jetty :as jetty]))
(defroutes helloworld-routes
(ANY "/" {} {:body "Hello Compojure!"})
(route/not-found "Page not found"))
(defproject comp1 "1.0.0-SNAPSHOT"
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
[compojure "0.5.3"]
[ring/ring-jetty-adapter "0.3.1"]]
:keep-non-project-classes true
:main comp1.core)