I have written some Clojurescript code that requires a REST interface for its communication with the server. The backend is currently in Python and I wanted to move it over to Clojure. Now I found rook https://github.com/AvisoNovate/rook which offers a nice API for REST which I was going to use.
However I would like to use ring (which is used by rook) to also serve some static content (basically html and JS of ClojureScript) on the same http server.
My setup is very similar to the one in the Rook example right now:
https://portal.aviso.io/#/document/open-source/rook/Current/example.html
(ns org.example.server (:import [org.eclipse.jetty.server Server]) (:require [ring.adapter.jetty :as jetty] [io.aviso.rook :as rook] [clojure.tools.logging :as l])) (defn start-server "Starts a server on the named port, and returns a function that shuts it back down." [port] (let [handler (-> (rook/namespace-handler ["counters" 'org.example.resources.counters]) rook/wrap-with-standard-middleware) ^Server server (jetty/run-jetty handler {:port port :join? false})] (l/infof "Listening on port %d." port) #(.stop server))) (defn main [] (start-server 8080))
I have no clear picture on how to get this running with the ring static resources functionalities: https://github.com/ring-clojure/ring/wiki/Static-Resources