Questions tagged [compojure]

Compojure is an open source web framework for the Clojure programming language.

Compojure

Author: James Reeves
Categories: web
License: EPL
Source code: https://github.com/weavejester/compojure

Dependencies: clojure.contrib, a Java servlet container (e.g. Jetty)

Compojure is a web framework that emphasizes a thin I/O layer and a functional approach to web development. It includes an integrated Jetty web server, but can be used with any Java servlet container.

FAQ

Useful links

442 questions
0
votes
2 answers

How to get Clojure Compojure app to run headless via compiled jar within Docker container?

Update: this question has changed since the original set of commenters left responses. Apologies for any confusion. This is my code repository https://github.com/Integralist/spurious-clojure-example you can use it as an example for what I'm working…
Integralist
  • 5,899
  • 5
  • 25
  • 42
0
votes
1 answer

Macros in Clojure, evaluation and quoting

I'm trying to write a macro to conditionally wrap compojure handler in a middleware only in certain environments. I seem to be lost in the evaluation order and what/how should I quote. My current attempt is as follows: (defn empty-middleware…
sumek
  • 26,495
  • 13
  • 56
  • 75
0
votes
2 answers

Is there some way to let compojure support type conversion automatically?

Now can use compojure this way: (GET ["/uri"] [para1 para2] ) Para1 and para2 are all of type String. I would like to let it know the type correcttly,like this: (GET ["/uri"] [^String para1 ^Integer para2] ) It can convert para1 to be Sting…
user2219372
  • 2,385
  • 5
  • 23
  • 26
0
votes
1 answer

Compojure multiple contexts

I have a defroutes like: (defroutes app-routes (context "first" [] (GET "/" [] "first first")) (context "second" [] (GET "/" [] "first second"))) But when I try to visit /second I just get a 404. What am I supposed to do?
dirtymikeandtheboys
  • 511
  • 2
  • 5
  • 17
0
votes
1 answer

How do I add webjars resources to lib-noir's app-handler?

How do I add webjars resources to lib-noir's app-handler? I used to do this only using Ring like this: (def app (-> handler (wrap-resource "public") (wrap-resource "/META-INF/resources") ;;resources from webjars )) Now I'm…
Michiel Borkent
  • 34,228
  • 15
  • 86
  • 149
0
votes
1 answer

Best way to customize Swagger / Compojure 404 response

In Compojure one can define default 404 behavior, e.g., (defroutes app-routes ;; ... (route/not-found "These aren't the droids you're looking for.")) As we've been increasing the number and complexity of REST endpoints, we've been looking into…
JohnJ
  • 4,753
  • 2
  • 28
  • 40
0
votes
1 answer

compojure POST request parameters are empty when app deployed to heroku

My code is very simple: (def form-test "
") (defroutes app-routes (GET "/" [] form-test) (POST "/"…
markg
  • 23
  • 5
0
votes
1 answer

Compojure Not Serving CSS When I Use Multiple Parameters

I'm trying to mimic Wordpress permalink using Compojure, but why all the static files (css, js, and img) are not found when I use multiple parameter? Here is my code. (defroutes approutes (GET "/" [] (posts-for-home)) (GET "/:year/:month/:title"…
0
votes
1 answer

Issue with function inside route (Clojure/Compojure)

I am with a issue on use the following code inside a route. (str "Size " (t/pay-billets-found)) ;-> "Size 2" The (t/pay-billets-found) return a integer. My routes code: (defroutes app-routes (POST "/upload" [] {:message (str "a "…
Édipo Féderle
  • 4,169
  • 5
  • 31
  • 35
0
votes
0 answers

Securing a local-only Compojure/Ring Webapp?

I want to create a Ring/Compojure webapp that would enable a clojure repl. All of this is meant to be running on a local machine and the webapp is just a convenient GUI for the local user. Since it is a enabling a repl, I want it to be secure. …
Roger Allen
  • 2,262
  • 17
  • 29
0
votes
1 answer

Where to initialize logging in a Compojure app?

I have a Compojure app generated using Luminus. I want to configure logging using clj-logging-config but I'm struggling mightily with this. I put the (!set-logger) command in the init function (declared with {:ring {:init} in project.clj) but I…
Matthew Gertner
  • 4,487
  • 2
  • 32
  • 54
0
votes
1 answer

Cleaning up state on code reload when running Ring and Compojure

I'm writing a Compojure based application and can't get the hang of how to handle cleaning up state when the code is reloaded. Specifically, my app has an open handle to a LevelDB database, and this needs to be either reused or closed properly…
Theo
  • 131,503
  • 21
  • 160
  • 205
0
votes
1 answer

Multiple optional parameters in Luminus / Compojure routes?

I would like to create a route that has multiple optional parameters, detected by the presence of a "keyword" in the URL, and processed in any…
user1559027
  • 343
  • 2
  • 13
0
votes
1 answer

Check if URL parameter exists in map

(defroutes my-routes (GET "/:id" [id] (html/display-thing id))) (def my-map {:id 1 :title "One" :id 2 :title "Two"}) Is there a nice way to check if the url parameter id exists in my-map else continue checking if the other routes match? I…
deadghost
  • 5,017
  • 3
  • 34
  • 46
0
votes
1 answer

Suppress Clojure errors in Compojure

I'm writing a web application in Clojure and sometimes I have an error at a specific route. I don't have the wrap stacktraces middleware running. But it shows the error still, not a stack trace but just a one line of the error like so and so…
Chris Bui
  • 1,055
  • 1
  • 13
  • 24