Questions tagged [ring]

Ring is a Clojure web applications library written by Mark McGranaghan. It was inspired by Python's WSGI and Ruby's Rack. By abstracting the details of HTTP into a simple, unified API, Ring allows web applications to be constructed of modular components that can be shared among a variety of applications, web servers, and web frameworks.

Ring is a Clojure web applications library written by Mark McGranaghan. It was inspired by Python's WSGI and Ruby's Rack. By abstracting the details of HTTP into a simple, unified API also known as the Ring spec, Ring allows web applications to be constructed of modular components that can be shared among a variety of applications, web servers, and web frameworks.

Mark gave a presentation which provided an overview of Ring at Clojure conj called "One Ring to Bind Them".

479 questions
63
votes
3 answers

How do I stop jetty server in clojure?

I am writing a web application using ring and clojure. I am using the jetty adapter for the development server and emacs/SLIME for IDE. While wrap-reload does help, run-jetty blocks my slime session and I would like to be able to start/stop it at…
Mad Wombat
  • 14,490
  • 14
  • 73
  • 109
42
votes
6 answers

Compojure routes with different middleware

I'm currently writing an API in Clojure using Compojure (and Ring and associated middleware). I'm trying to apply different authentication code depending on the route. Consider the following code: (defroutes public-routes (GET "/public-endpoint"…
user1391110
37
votes
1 answer

Can I make a fully non-blocking backend application with http-kit and core.async?

I'm wondering if it's possible to put together a fully non-blocking Clojure backend web application with http-kit. (Actually any Ring-compatible http server would be fine by me; I'm mentioning http-kit because it claims to have an event-driven,…
Valentin Waeselynck
  • 5,950
  • 26
  • 43
19
votes
4 answers

Why does the order of Ring middleware need to be reversed?

I'm writing some middleware for Ring and I'm really confused as to why I have to reverse the order of the middleware. I've found this blog post but it doesn't explain why I have to reverse it. Here's a quick excerpt from the blog post: (def app …
Chris Bui
  • 1,055
  • 1
  • 13
  • 24
17
votes
4 answers

In clojure/ring, how do I delete a cookie?

Suppose I want to delete a cookie (for example, ring's session cookie): Making a response map like this: {:cookies {"ring-session" {:value "kill", :max-age 1}}} seems to work, but it feels a bit hacky. Is there a clean way to just delete it?
John Lawrence Aspden
  • 17,124
  • 11
  • 67
  • 110
15
votes
3 answers

How to convert map to URL query string in Clojure/Compojure/Ring?

In Clojure / Compojure, how do I convert a map to a URL query string? {:foo 1 :bar 2 :baz 3} to foo=1&bar=2&baz=3 Is there any utility method to do this in compojure?
Sathish
  • 20,660
  • 24
  • 63
  • 71
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
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
3 answers

Reading Ring request body when already read

My question is, how can I idiomatically read the body of a Ring request if it has already been read? Here's the background. I'm writing an error handler for a Ring app. When an error occurs, I want to log the error, including all relevant…
Jeff Terrell Ph.D.
  • 2,563
  • 26
  • 39
13
votes
1 answer

Set Ring-Anti-Forgery CSRF header token

I'm attempting to implement the Ring-Anti-Forgery library via setting the X-CSRF-Token in the header. Since I am using static html files I found the built-in hiccup helper, which sets the token in the form, to be useless. This is my first stab at…
jasonshell
  • 352
  • 6
  • 12
12
votes
1 answer

EOF exception while reading clojure file

When I run the web application in the ring jetty server, I got EOF exception, I can't fix this, since there is no clue on which line the error has occurred. I'm using compojure and hiccup on my clojure code. I'm using Emacs 23 as editor. Here is the…
Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
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
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
1
2 3
31 32