wip: feat: basic publisher
All checks were successful
build / build (push) Successful in 8s

This commit is contained in:
2026-03-20 17:19:55 -06:00
parent 5bca7890c4
commit fcd37feb2a
6 changed files with 579 additions and 159 deletions

View File

@@ -1,23 +1,15 @@
{:deps {org.clojure/clojure {:mvn/version "1.12.0"}
http-kit/http-kit {:mvn/version "2.8.0"}
org.clojure/tools.logging {:mvn/version "1.3.0"}
hiccup/hiccup {:mvn/version "2.0.0-RC4"}
compojure/compojure {:mvn/version "1.7.1"}
org.clojars.pntblnk/clj-ldap {:mvn/version "0.0.17"}
ring/ring-defaults {:mvn/version "0.6.0"}
babashka/fs {:mvn/version "0.5.24"}
org.clojure/core.match {:mvn/version "1.1.0"}
com.github.seancorfield/next.jdbc {:mvn/version "1.3.1070"}
org.xerial/sqlite-jdbc {:mvn/version "3.47.1.0"}
cheshire/cheshire {:mvn/version "6.1.0"}
instaparse/instaparse {:mvn/version "1.5.0"}
babashka/process {:mvn/version "0.6.25"}
org.clojure/test.check {:mvn/version "1.1.2"}
#_#_
io.github.msyds/spec-dict
{:git/sha "531d629b7f05f37232261cf9e8927a4b5915714f"}
net.deertopia/doerg {:local/root "../doerg"}}
:paths ["src" "resources" "test"]
:aliases
{:dev
{:extra-deps {vvvvalvalval/scope-capture-nrepl {:mvn/version "0.3.1"}}}}}
net.deertopia/doerg {:local/root "../doerg"}
metosin/reitit {:mvn/version "0.10.1"}
http-kit/http-kit {:mvn/version "2.8.0"}}
:paths ["src" "resources" "test"]}

View File

@@ -1,7 +1,7 @@
(ns net.deertopia.publisher.main
(:require [net.deertopia.doerg.main :as doerg])
(:require [net.deertopia.doerg.main :as doerg]
[net.deertopia.publisher.server :as server])
(:gen-class))
(defn -main []
(doerg/-main)
(println "hi from publisher"))
(server/start!))

View File

@@ -0,0 +1,61 @@
(ns net.deertopia.publisher.server
(:require [clojure.pprint :refer [pprint]]
[clojure.tools.logging :as l]
[hiccup2.core :as hiccup]
[net.deertopia.doerg.html :as doerg-html]
[org.httpkit.server :as http]
[reitit.ring]
[ring.util.response :as response]))
(defn hello [req]
(-> (hiccup/html {}
[:html
[:head
[:title "hello"]
doerg-html/charset
doerg-html/viewport]
[:body
[:pre
(with-out-str
(pprint req))]]])
str
response/response
(response/content-type "text/html")))
(def router
(reitit.ring/router
#{["/" {:get hello}]}))
(def app (reitit.ring/ring-handler router))
(defonce server (atom nil))
(defn stop! []
(when @server
(http/server-stop! @server {:timeout 100})
(reset! server nil)
(l/info "Stopped server")))
;; For some reason, the log messages from `stop!` are not flushed
;; before the JVM shuts dowm. Nevertheless, the server /does/ come to
;; a graceful halt.
(def ^:private shutdown-hook (Thread. stop!))
(defn start! []
(if @server
(let [msg "Server already started"]
(throw (ex-info msg {})))
(do (reset! server
(http/run-server (bound-fn* #'app)
{:port 8080
:legacy-return-value? false}))
;; For some reason, the log messages are not flushed before
;; the JVM shuts dowm. Nevertheless, the server /does/ come
;; to a graceful halt.
(.addShutdownHook (Runtime/getRuntime) shutdown-hook)
(l/info "Server started on port 8080"))))
(defn status []
(if @server
(http/server-status @server)
:stopped))