1- = The Duct Framework
1+ = Duct
22James Reeves
33{docdate}
44:doctype: book
55:encoding: UTF-8
66:lang: en
7- :source-highlighter: coderay
7+ :source-highlighter: highlight.js
8+ :highlightjs-theme: ir-black
9+ :highlightjs-languages: clojure, clojure-repl, json, shell
810:sectnums:
11+ :linkcss:
12+ :stylesheet: reset.css
913:toc: left
14+ :title: The Duct Framework
1015:url-repo: https://github.com/duct-framework/duct-framework.github.io
1116:experimental:
1217:docinfo: shared
1318
19+ [discrete]
20+ = The Duct Framework
21+
1422== Introduction
1523
1624Duct is a framework for developing server-side applications in the
@@ -215,7 +223,7 @@ user=>
215223In the REPL environment the system will not be initiated automatically.
216224Instead, we use the inbuilt `(go)` function.
217225
218- [,clojure]
226+ [,clojure-repl ]
219227----
220228user=> (go)
221229Hello World
@@ -226,7 +234,7 @@ The REPL can be left running while source files updated. The `(reset)`
226234function will halt the running system, reload any modified source files,
227235then initiate the system again.
228236
229- [,clojure]
237+ [,clojure-repl ]
230238----
231239user=> (reset)
232240:reloading (tutorial.print)
@@ -239,7 +247,7 @@ You can also use the kbd:[Alt-E] hotkey instead of typing `(reset)`.
239247The configuration defined by `duct.edn` can be accessed with `config`,
240248and the running system can be accessed with `system`.
241249
242- [,clojure]
250+ [,clojure-repl ]
243251----
244252user=> config
245253#:tutorial.print{:hello {}}
@@ -509,7 +517,7 @@ $ duct --main
509517
510518But when using the REPL, we get a more concise message.
511519
512- [,shell ]
520+ [,clojure-repl ]
513521----
514522user=> (go)
515523:initiated
@@ -806,9 +814,9 @@ we have no routes defined. The error page will be in plaintext, because
806814we haven't specified what _features_ we want for our web application.
807815
808816We'll fix both these issues, but before we do we should terminate the
809- application with Ctrl-C and start a REPL. We'll keep this running while
810- we develop the application to avoid costly restarts and to give us a way
811- of querying the running system.
817+ application with kbd:[ Ctrl-C] and start a REPL. We'll keep this running
818+ while we develop the application to avoid costly restarts and to give
819+ us a way of querying the running system.
812820
813821[,shell]
814822----
@@ -859,7 +867,7 @@ returns a Hiccup data structure.
859867
860868Finally, we trigger a `(reset)` at the REPL.
861869
862- [,shell ]
870+ [,clojure-repl ]
863871----
864872user=> (reset)
865873:reloading (todo.routes)
@@ -1118,7 +1126,7 @@ Our project dependencies should now look like this:
11181126We can load these new dependencies either by restarting the REPL, or by
11191127using the `sync-deps` function.
11201128
1121- [,clojure]
1129+ [,clojure-repl ]
11221130----
11231131user=> (sync-deps)
11241132[...]
@@ -1139,7 +1147,7 @@ The next step is to add `:duct.module/sql` to our Duct configuration.
11391147
11401148Then reset via the REPL:
11411149
1142- [,shell ]
1150+ [,clojure-repl ]
11431151----
11441152user=> (reset)
11451153:reloading ()
@@ -1174,7 +1182,7 @@ used in development.
11741182If we want to change this in production, we can use the corresponding
11751183command-line argument or environment variable to override this default.
11761184
1177- [,shell ]
1185+ [,clojure-repl ]
11781186----
11791187user=> (reset)
11801188:reloading ()
@@ -1277,7 +1285,7 @@ create a table to store the todo list items.
12771285
12781286When we reset the REPL, the migration is automatically applied.
12791287
1280- [,shell ]
1288+ [,clojure-repl ]
12811289----
12821290user=> (reset)
12831291:reloading (todo.routes)
@@ -1347,7 +1355,7 @@ combined with `execute!`.
13471355We can reset via the REPL and add some test data with the `sql`
13481356convenience function.
13491357
1350- [,shell ]
1358+ [,clojure-repl ]
13511359----
13521360user=> (reset)
13531361:reloading (todo.routes)
@@ -1965,6 +1973,7 @@ Once CIDER has connected, you can open a REPL with: kbd:[C-c] kbd:[C-z]
19651973This works in a similar way to the command-line REPL. To start up Duct,
19661974you can use the `(go)` command:
19671975
1976+ [,clojure]
19681977----
19691978user> (go)
19701979----
@@ -2001,7 +2010,7 @@ print the expression, its value, and its location in your project.
20012010
20022011For example, at the REPL:
20032012
2004- [,clojure]
2013+ [,clojure-repl ]
20052014----
20062015user=> (* 2 #p (+ 1 1))
20072016#p[user/eval11138:1] (+ 1 1) => 2
@@ -2021,7 +2030,7 @@ possible to use Duct with Leiningen.
20212030To do so, you'll need to update your project file with profile for Duct,
20222031and an alias to run it:
20232032
2024- .project
2033+ .project.clj
20252034[,clojure]
20262035----
20272036(defproject org.example/app "0.1.0-SNAPSHOT"
@@ -2069,6 +2078,7 @@ TIP: Use kbd:[Ctrl-Shift-P] to open the command palette.
20692078You'll be presented with a REPL where you can start the application
20702079with `(go)`
20712080
2081+ [,clojure]
20722082----
20732083clj꞉user꞉> (go)
20742084----
0 commit comments