This file contains 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
(defn spicy [first second third] | |
(println "I like food with" first "," second "and" third ".")) | |
(def curry-and-chilli | |
(partial spicy "curry" "curry" "chilli")) | |
(curry-and-chilli) | |
;; -> I like food with curry , curry and chilli . |
This file contains 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 blog-ring.core | |
(:require [ring.adapter.jetty :as jetty])) | |
(defn handler [request] | |
{:status 200 | |
:headers {"Content-Type" "text/html"} | |
:body "<h1>Hello, world!</h1>"}) | |
(defn -main [] | |
(jetty/run-jetty handler |
This file contains 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
(defproject blog-ring "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.8.0"] | |
[ring "1.6.0-RC2"]] | |
:main blog-ring.core) |
This file contains 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 blog-ring.response | |
(:require [ring.util.response :as res])) | |
(def simple-res (res/response "Hello, world!")) | |
simple-res | |
;; -> {:status 200, | |
;; :headers {}, | |
;; :body "Hello, world!"} |
This file contains 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
(defn handler [request] | |
{:status 200 | |
:headers {"Content-Type" "text/html"} | |
:body (str "<h1>One Ring rules them all!</h1>" | |
"<ul><li>Request from IP: " | |
(:remote-addr request) | |
"</li><li>Request method: " | |
(:request-method request) | |
"</li><li>Headers: " | |
(select-keys |
This file contains 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 blog-ring.middleware | |
(:require [ring.middleware.params :refer [wrap-params]] | |
[ring.middleware.keyword-params :refer [wrap-keyword-params]])) | |
((wrap-params identity) | |
{:query-string "clojure=yes&lisp=maybe"}) | |
;; -> {:query-string "clojure=yes&lisp=maybe", | |
;; :form-params {}, | |
;; :params {"clojure" "yes", "lisp" "maybe"}, | |
;; :query-params {"clojure" "yes", "lisp" "maybe"}} |
This file contains 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
(def app | |
(-> handler | |
(wrap-keyword-params) | |
(wrap-params))) |
This file contains 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 blog-ring.core | |
(:require [ring.adapter.jetty :as jetty] | |
[ring.util.response :refer [response]] | |
[ring.middleware.params :refer [wrap-params]] | |
[ring.middleware.keyword-params :refer [wrap-keyword-params]])) | |
(defn handler [request] | |
(response | |
(str "<h1>One Ring rules them all!</h1>" | |
"<ul><li>Query string: " |
This file contains 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
swagger: "2.0" | |
info: | |
version: "0.1.0" | |
title: "The Ultimate Question." | |
paths: | |
/question: | |
get: | |
summary: "Asks the ultimate question" |
This file contains 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
plugins { | |
id 'org.hidetake.swagger.generator' version '2.4.2' | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile 'io.swagger:swagger-annotations:1.5.10' |