Skip to content

Commit 7d2b7f8

Browse files
committed
Use clj->erl and simplify cowboy configuration
1 parent 6601ae8 commit 7d2b7f8

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

rebar.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{ deps
2-
, [ {clojerl, "0.6.0"}
2+
, [ {clojerl, {git, "https://github.com/clojerl/clojerl.git", {branch, "master"}}}
33
, {hiccup, {git, "https://github.com/clojerl/hiccup.git", {branch, "clojerl"}}}
44
, {lager, "3.7.0"}
55
, {cowboy, "2.6.3"}

src/try_clojerl/app.clje

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@
1212
state)
1313

1414
(def routes
15-
{:_ [["/" :try-clojerl.layout :index]
16-
["/about" :try-clojerl.layout :about]
17-
["/repl" :try-clojerl.repl nil]
18-
["/css/[...]" :cowboy_static #erl[:priv_dir :try_clojerl "css"]]
19-
["/img/[...]" :cowboy_static #erl[:priv_dir :try_clojerl "img"]]
20-
["/js/[...]" :cowboy_static #erl[:priv_dir :try_clojerl "js"]]]})
21-
22-
(defn- route->cowboy [[host handlers]]
23-
#erl[host (->erl (map into-tuple handlers))])
15+
'{:_ (["/" :try-clojerl.layout :index]
16+
["/about" :try-clojerl.layout :about]
17+
["/repl" :try-clojerl.repl nil]
18+
["/css/[...]" :cowboy_static [:priv_dir :try_clojerl "css"]]
19+
["/img/[...]" :cowboy_static [:priv_dir :try_clojerl "img"]]
20+
["/js/[...]" :cowboy_static [:priv_dir :try_clojerl "js"]])})
2421

2522
(defn start-cowboy []
26-
(let [routes (->erl (map route->cowboy routes))
23+
(let [routes (-> routes clj->erl maps/to_list)
2724
dispatch (cowboy_router/compile routes)
28-
transport-opts (maps/to_list (->erl {:port 8080}))
29-
protocol-opts (->erl {:env {:dispatch dispatch}})]
25+
transport-opts (-> {:port 8080} clj->erl maps/to_list)
26+
protocol-opts (clj->erl {:env {:dispatch dispatch}})]
3027
(cowboy/start_clear :try-clojerl.listener transport-opts protocol-opts)))

0 commit comments

Comments
 (0)