Created
September 6, 2025 08:39
-
-
Save borkdude/9b93dc832f6c89ffeb68425ae4d5809e to your computer and use it in GitHub Desktop.
clj-simple-router with babashka
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (require '[babashka.deps :as deps]) | |
| (deps/add-deps '{:deps {io.github.tonsky/clj-simple-router {:mvn/version "0.1.2"}}}) | |
| (require '[org.httpkit.server :as server] | |
| '[clj-simple-router.core :as router]) | |
| (def routes | |
| (router/routes | |
| "GET /" [] | |
| (do | |
| {:status 200 | |
| :body "<html><body><h1>It’s working!</h1></body></html>"}) | |
| ;; inline parameter | |
| "GET /pages/*" [page-name] | |
| {:status 200 | |
| :body "page"} | |
| ;; parameter from request | |
| "GET /pages/*/*" req | |
| {:status 200 | |
| :body (str (:path-params req))})) | |
| (server/run-server (router/router routes) {:port 11337}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment