Skip to content

Commit 2aaad3a

Browse files
committed
section 2 video 4 update
1 parent acd7a9e commit 2aaad3a

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
:license {:name "Eclipse Public License"
55
:url "http://www.eclipse.org/legal/epl-v10.html"}
66
:plugins [[lein-ring "0.8.7"]]
7-
:ring {:handler project1.core/example-handler
7+
:ring {:handler project1.core/route-handler
88
:init project1.core/on-init
99
:port 4001
1010
:destroy project1.core/on-destroy}

src/project1/core.clj

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
(ns project1.core)
1+
(ns project1.core
2+
(:require [project1.handlers :as handlers]))
23

34
(defn example-handler [request]
45
{:headers {"Location" "http://github.com/ring-clojure/ring"
@@ -16,3 +17,16 @@
1617
"I don't do a whole lot."
1718
[x]
1819
(println x "Hello, World!"))
20+
21+
(defn test1-handler [request]
22+
{:body "test1"})
23+
24+
(defn test2-handler [request]
25+
{:status 301 :headers {"Location" "http://github.com/ring-clojure"}})
26+
27+
(defn route-handler [request]
28+
(condp = (:uri request)
29+
"/test1" (test1-handler request)
30+
"/test2" (test2-handler request)
31+
"/test3" (handlers/handler3 request)
32+
nil))

src/project1/handlers.clj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
(ns project1.handlers)
2+
3+
(defn handler3 [request]
4+
{:body "this is project1.handlers/handler3"})
5+

0 commit comments

Comments
 (0)