Liking cljdoc? Tell your friends :D

Library Development

This guide is a modified version of the installation guide which demonstrates how to use it for library development. You should be loosely familiar with that guide, as we won’t go into as much detail here.

You would use this if you’re developing a stateful library such as a ring handler (which is dependent on the ring server which is stateful). There’s other ways to develop for those situations, but using Wedge can provide a comfortable system-like approach. This guide will assume Clip, as it’s the easiest to "clip on" to an existing library. But you can swap it out for any other set of system dependencies you prefer.

Setting up your dev alias

Whatever you do to launch a "dev" setup while working on your library will need:

  • Dependencies on Wedge, and System dependencies (Aero, Clip).

  • A folder on the classpath for dev-only files (usually named dev)

For a deps.edn, this would normally be achieved with a :dev alias.

Example for deps.edn
{:aliases
 {:dev {:extra-paths ["dev"]
        :extra-deps {aero/aero {:mvn/version "…"}
                     juxt/clip {:mvn/version "…"}
                     io.dominic/wedge {:mvn/version "…"}
                     io.dominic/wedge-mise {:git/url ""https://git.sr.ht/~severeoverfl0w/wedge-mise"
                                            :sha "…"}}}}}

Configuring Wedge

Next, we need to create a few files for Wedge to be loaded.

dev/user.clj
(ns user
  (:require
    [io.dominic.wedge.user :refer :all]))
dev/dev.clj
(ns dev
  (:require
    [io.dominic.wedge.dev :refer :all]))
dev/io/dominic/wedge/system-config.edn
{:system io.dominic.wedge.clip-aero
 :dev {:profile :dev}}

Configuring Your Library

Finally, we need to create a config.edn and configure our system.

dev/config.edn
{:clip/system
 {:components
  {:http-server {:start (ring.adapter.jetty/run-jetty {:port 2344
                                                       :join? false
                                                       :handler (clip/ref :handler)})
                 :stop (.stop this)}
   :handler {:start (my.cool.lib/handler {:user #env USER})}}}}

Run it

Now you can run Wedge like normal:

$ clj -M:dev
user=> (dev)
dev=> (go)

Can you improve this documentation?Edit on sourcehut

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close