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
8
votes
3 answers

ring: read body of a http request as string

When handling a http request inside a ring server, the body of the request-data is stored in the request-hashmap in the key :body. For instance as followed: #object[org.eclipse.jetty.server.HttpInputOverHTTP 0x2d88a9aa "HttpInputOverHTTP@2d88a9aa"]…
Anton Harald
  • 5,772
  • 4
  • 27
  • 61
8
votes
1 answer

Invalid anti-forgery token

I'm getting an "Invalid anti-forgery token" when I try using POST method in a Clojure Webapp project I created using Compojure template. I researched, and Ring middle ware creates CSRF (cross site request forms) tokens to authenticated requests…
8
votes
1 answer

Basic logging in Clojure web service not appearing on console

I am following this tutorial to set up application logging in my Clojure web app, which I am going to be using for some Datomic experimentation. The tutorial suggests that all I have to do is add Clojure's clojure.tools.logging library to my…
Owen S.
  • 7,665
  • 1
  • 28
  • 44
8
votes
2 answers

How to use figwheel with a ring-handler that's a component?

I'd like to use figwheel to reload the frontend of an all-clojure project I'm playing with. The backend serves a REST api and is organized as a bunch of components from which I create a system in my main function (I use duct to create the handler…
Tom Dunham
  • 5,779
  • 2
  • 30
  • 27
8
votes
3 answers

How to get the client IP address in ring-clojure?

When a visitor submit a form, I'd like to assoc to inputs his IP adress. (POST "/form" {params :params} (assoc params :ip-address the-ip) How to do this? Thought of doing this: (POST "/form" {params :params client-ip…
leontalbot
  • 2,513
  • 1
  • 23
  • 32
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
1 answer

What is the attr-map of a clojure function defined by defn?

As a clojure beginner, I am reading clojure code to get myself familiar with Clojure's grammar. Below code snippet is a function in Ring project (defn- request-context "Create an UploadContext object from a request map." {:tag…
danny
  • 3,046
  • 3
  • 23
  • 28
8
votes
2 answers

Static files with clojure and ring

I am building a test clojure/ring project to learn how it works. I created an app I call "junkapp" and it has really one handler (defn handler [request] {:status 200 :headers {"Content-type" "text/html"} :body "Hello World"}) And also one…
MichaelB
  • 1,092
  • 2
  • 16
  • 32
8
votes
2 answers

How to print to the REPL window in a Ring handler?

(defn app [request] (println "test") {:body "Hello World"}) (defonce server (run-jetty #'app {:port 8080 :join? false})) println doesn't seem to work in a handler. How do I write to the REPL window? I'm using eclipse with…
alice
  • 2,547
  • 4
  • 24
  • 30
8
votes
1 answer

clojure and ring: utf-8 in responses comes through as '?'

I was surprised to find my ring app was not serving utf-8 properly. I pared this down to a simple test case, does anyone know how to ensure that this will always return utf-8 to the browser? (ns utf8test.core) (defn app [request] {:status…
prismofeverything
  • 8,799
  • 8
  • 38
  • 53
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

Does Clojure Ring create a thread for each request?

I am making a Messenger bot and I am using Ring as my http framework. Sometime I want to apply delays between messages sent by the bot. My expectation would be that it is safe to use Thread/sleep because this will make the active thread sleep and…
feychu
  • 1,284
  • 1
  • 14
  • 33
7
votes
2 answers

Clojure ring middleware to handle url array

The ClojureScript cljs-ajax client library converts {:b [1 2]} to b[0]=1&b[1]=2 For example: (http/get "http://example.com" {:b [1 2]}) results in a request to: "http://example.com?b[0]=1&b[1]=2" How can I setup my ring middleware to handle this…
Mamun
  • 512
  • 3
  • 10
7
votes
1 answer

Has anyone used Incanter in a web app to serve statistical graphs?

I'd like to serve up statistical graphs based on Incanter with a framework like Ring or Compojure in a Clojure environment. I haven't seen any examples or links that do this. Could someone steer me toward working examples? Would Enlive help out…
simon-says
  • 71
  • 1
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
1 2
3
31 32