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
15
votes
2 answers

Serving static files with ring/compojure - from a war

Using ring (and the lein-ring tools) - I am able to serve up static files from "resources" etc as per the docs when running in development - however - when I package things up via lien uberwar I have no idea how to make it serve those files when…
Michael Neale
  • 19,248
  • 19
  • 77
  • 109
15
votes
2 answers

Serving app and api routes with different middleware using Ring and Compojure

I have a ring+compojure application and I want to apply different middleware depending on whether the route is part of the web application or part of the api (which is json based). I found some answers to this question on stack overflow and other…
Tim X
  • 4,158
  • 1
  • 20
  • 26
14
votes
2 answers

Optional query parameters (with default value) with compojure-api

What is the proper way to declare an optional query parameter, with default value, when using compojure-api? One of my route elements is as follows (after reading this): (GET "/:id/descendants" [id] :return [d/CategoryTreeElement] …
Matheus Moreira
  • 2,338
  • 4
  • 24
  • 31
14
votes
3 answers

Escape/sanitize user input in Clojure/Compojure

I am using Clojure/Ring/Compojure-0.4/Enlive stack to build a web application. Are there functions in this stack that would either strip HTML or HTML-encode (i.e. to <a>) user-supplied strings in order to prevent XSS attacks?
Alex B
  • 82,554
  • 44
  • 203
  • 280
14
votes
3 answers

Passing state as parameter to a ring handler?

How does one inject state into ring handlers most conveniently (without using global vars)? Here is an example: (defroutes main-routes (GET "/api/fu" [] (rest-of-the-app the-state))) (def app (-> (handler/api main-routes))) I would like to get…
4ZM
  • 1,463
  • 1
  • 11
  • 21
14
votes
1 answer

How to run an arbitrary startup function in a ring project?

I've got a compojure/ring application I currently run with lein ring server that I'd like to compile to a .war so I can deploy it. I've got a definition, however, just like (def foo (start-scheduler)) That blocks the compilation and the generation…
konr
  • 2,545
  • 2
  • 20
  • 38
13
votes
2 answers

All-in-one solution for using OAuth2 with Compojure

I am trying to integrate a compojure application with those OAuth2 providers: LinkedIn, Facebook, Google, and Twitter, using an all in one solution. I am aware of some existing java libraries such as scribe-java or spring-social that can help. But…
user258030
  • 399
  • 3
  • 10
12
votes
8 answers

webjure vs compojure?

I've heard of two Clojure based web application frameworks: Webjure and Compojure. Can someone let me know which is better?
user43737
  • 791
  • 1
  • 8
  • 9
12
votes
1 answer

How do you use sessions with Compojure/Ring?

I'm developing a web application using Compojure and I would hugely appreciate a small and complete example of storing and retrieving session data. Many thanks in advance, James.
James
  • 2,306
  • 1
  • 22
  • 23
12
votes
7 answers

How to find a web hosting service for running Compojure

I am very interested in building a website using Clojure and Compojure, like so: http://briancarper.net/blog/deploying-clojure-websites However, due to my limited experience with the Java environment and Java culture, I am not sure where to begin…
kes
  • 5,983
  • 8
  • 41
  • 69
12
votes
3 answers

What's the relationship between Leiningen, Compojure, Luminus and Ring?

I'm starting my new learning phase of Clojure. I want to build a web application, but I don't know which one to use. I've searched for several hours online, and all the things I found kind of overlap each other and I'm a little bit confused by…
albusshin
  • 3,930
  • 3
  • 29
  • 57
12
votes
2 answers

ring-json's wrap-json-response middleware and compojure returns text/plain?

I'm trying to use ring-json's wrap-json-response middleware within my compojure app. I have a simple GET handler that returns a map, like {:foo 1}, and when I hit the URL, ring responds with text/plain and an empty response body. I can't seem to get…
Ryan
  • 7,733
  • 10
  • 61
  • 106
11
votes
2 answers

Compojure or Noir for a UI-less webservice?

If one is planning to create a UI-less web service (receives JSON and/or XML, returns JSON and/or XML), does Noir provide anything useful over and above Compojure?
Paul Butcher
  • 10,722
  • 3
  • 40
  • 44
11
votes
4 answers

Accessing Compojure query string

I'm trying to pull a value out of the url query string however I can return what I believe is a map, however when i use the below code, it doesn't process it as expected. Can anyone advise how I access specific values in the returned querystring…
Dale
  • 579
  • 1
  • 7
  • 13
11
votes
1 answer

Compojure: how to map query parameters

I'm trying to make any of the following mappings work to map http://mysite.org/add?http://sitetoadd.com or http://mysite.org/add?u=http://sitetoadd.com (GET "/add?:url" [url] url) (GET "/add?u=:url" [url] url) (GET "/add" {params :params}…
pistacchio
  • 56,889
  • 107
  • 278
  • 420
1
2
3
29 30