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
8
votes
1 answer

lein ring server: "That's not a task"

I'm trying to build the hello-world example for compojure and it's failing to start the ring task. $ lein version Leiningen 1.7.1 on Java 1.7.0_65 OpenJDK 64-Bit Server VM $ lein new compojure test Created new project in: /home/myaccount/test Look…
voodoogiant
  • 2,118
  • 6
  • 29
  • 49
8
votes
2 answers

Create a HTML table from nested maps (and vectors)

I'm trying to create a table (a work schedule) I have coded previously using python, I think it would be a nice introduction to the Clojure language for me. I have very little experience in Clojure (or lisp in that matter) and I've done my rounds in…
Kenny164
  • 53
  • 1
  • 8
8
votes
3 answers

What is the correct way to use emacs/cider while developing a compojure/ring-based application?

What is the correct workflow/pathway of usage of emacs/cider while developing a compojure/ring-based clojure application? I feel that I can "attach" to my running compojure/ring-process, change its code, read/change its data, but I can't understand…
Igor Chubin
  • 61,765
  • 13
  • 122
  • 144
8
votes
2 answers

how to you access :headers inside compojure function

org.clojure/clojure-contrib "1.2.0" ring "1.1.8" compojure "1.1.5" clout "1.1.0" (defroutes rest-routes (GET "/" [] "

Hello

") (POST "/api/v1/:stor/sync" [stor] (start-sync stor)) (POST ["/api/v1/:stor/:txn/data/:file" :file…
8
votes
2 answers

How to get repeating request parameters in Compojure

I can get to the request parameters easily with: (:foo params) However, when I have a request like this: /api?foo=1&foo=2&foo=3 I only get back "3" while I would expect an array ["1","2","3"]. I'm not sure why this is happening because when I look…
Stefan Arentz
  • 34,311
  • 8
  • 67
  • 88
8
votes
1 answer

Compojure Templating Pages

I have a bunch of static html files that share same header and footer. I would like to share this header and footer across all pages. For now i use the following routed but it is a bit ugly, and i have to take care of all special cases. Is there an…
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
7
votes
3 answers

Compojure regex for matching a trailing slash

Maybe I'm just an idiot, but I can't set up a match for an optional trailing slash in Clojure. lein repl REPL started; server listening on localhost port 47383 user=> (use 'ring.mock.request 'clout.core) nil user=> (route-matches "/article/"…
Kevin Burke
  • 61,194
  • 76
  • 188
  • 305
7
votes
2 answers

Compojure: lein-ring in production?

It seems that people sugget the use of lein-ring for a no-brainer deploy of a Compojure application. Isn't it just meant for development? I've benchmarked the same app running with lein-ring vs packed by leiningen with uberjar (executed with java…
pistacchio
  • 56,889
  • 107
  • 278
  • 420
7
votes
1 answer

How to use CORS with JSON Response in Compojure?

I am creating a simple API which returns JSON data back to the user. For development purposes, I would like to enable CORS so that my react frontend can call the API locally. For the moment, it complains Response to preflight request doesn't pass…
Jeel Shah
  • 3,274
  • 17
  • 47
  • 68
7
votes
2 answers

Serving binary files from the database with compojure

I have the following routes definition: (require '[compojure.core :as ccore] '[ring.util.response :as response]) (def *main-routes* (ccore/defroutes avalanche-routes (ccore/GET "/" [] "Hello World 2") (ccore/GET…
Pieter Breed
  • 5,579
  • 5
  • 44
  • 60
7
votes
3 answers

How to get all the params of a POST request with Compojure

According to the Compojure documentation on routes, I can easily get individual parameters like this: (POST "/my-app" [param1 param2] (str "

Hello " param1 " and " param2 "

")) How do I get all parameters, not just individual parameters?
at.
  • 50,922
  • 104
  • 292
  • 461
7
votes
1 answer

How can I use ring anti-forgery / CSRF token with latest version ring/compojure?

I copied some old code that was working in compojure 1.1.18 and other old libs, but using the latest versions I can't get it to work. Here's my minimal example code copied from the minimal example here to demonstrate that with latest ring and…
sventechie
  • 1,859
  • 1
  • 22
  • 51
7
votes
1 answer

How to serve the stream pdf with ring

I'm trying to serve a clj-http generated document directly via ring/compojure. I thought ring.util/piped-output-stream would work, but it seems I'm not understanding something here... This: (defn laminat-pdf-t [natno] (piped-input-stream (fn…
mathiasp
  • 81
  • 5
7
votes
1 answer

How to set Content-Type header on Ring-Compojure application

I'm trying to get started with Clojure and Clojurescript by implementing a simple web app. Things are going pretty good so far and reading from different tutorials I've come up with the code below: core.clj: (ns myapp.core (:require [compojure.core…
slhsen
  • 606
  • 9
  • 21
7
votes
1 answer

Clojure web frameworks for responsive apps

I have recently inherited a non-finished web app written in Clojure, based on compojure and hiccup basically. It's a bad attempt to model some sort of MVC with OO style not in the FP style as seen here . So I bet to re-start the project almost from…
Jaime Agudo
  • 8,076
  • 4
  • 30
  • 35