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

ring redirect after login

(ns ... (:require [ring.util.response :refer [ response redirect])) My original code be-all-like (-> (response "You are now logged in! communist party time!") (assoc :session new-session) (assoc :headers {"Content-Type"…
sova
  • 5,468
  • 10
  • 40
  • 48
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
3 answers

How to build clojure application with ring server

I got clojure project with ring library in it. This is project.clj: (defproject words "1.0.0-SNAPSHOT" :description "Websocket handler for sessions" :dependencies [[org.clojure/clojure "1.4.0"] [org.clojure/clojure-contrib "1.2.0"] [aleph…
jurka
  • 12,945
  • 3
  • 22
  • 20
7
votes
8 answers

How to block external http requests? (securing AJAX calls)

I want to use post to update a database and don't want people doing it manually, i.e., it should only be possible through AJAX in a client. Is there some well known cryptographic trick to use in this scenario? Say I'm issuing a GET request to insert…
Peteris
  • 3,548
  • 4
  • 28
  • 44
6
votes
1 answer

Clojure/Ring: Using the ring jetty adapter, large requests give me a 413: FULL HEAD error.

Using Ring's Jetty adapter, if my request is too large I get a 413: FULL HEAD error. I tracked it down to a property called headerbuffersize, but when I try to set it in the run-jetty call, I still get the 413's. Is there a better way to control…
prismofeverything
  • 8,799
  • 8
  • 38
  • 53
6
votes
1 answer

How to apply ring-anti-forgery on specific reitit routes?

I keep getting "Invalid anti-forgery token" when wrapping specific routes created with metosin/reitit reitit.ring/ring-router. I've also tried reitit's middleware registry, but it didn't work too. Although I could just wrap the entire handler with…
shaolang
  • 995
  • 11
  • 25
6
votes
2 answers

Clojure encode Joda DateTime with ring-json

With the following app: ; src/webapp/core.clj (ns webapp.core (:require [compojure.core :refer [defroutes GET]] [ring.middleware.json :as mid-json] [clj-time.jdbc])) (defn foo [request] {:body {:now…
Jacob O'Bryant
  • 311
  • 2
  • 10
6
votes
1 answer

Using piped-input-stream from ring.utils.io to serve files

I need to create on the fly excel file on request and serve it to user via response, using clojure.ring. I use docjure to create an excel file and write it to the output stream (see this function:…
Twice_Twice
  • 527
  • 4
  • 16
6
votes
1 answer

Clojure what does #' mean

I am following this tutorial building a Clojure backend and I'm not exactly well versed in Clojure. The tutorial provides this source file (ns shouter.web (:require [compojure.core :refer [defroutes GET]] [ring.adapter.jetty :as…
Chris Edwards
  • 1,518
  • 2
  • 13
  • 23
6
votes
1 answer

what is the relationship between Ring and Pedestal - do I need to know Ring to use Pedestal?

I was led to believe that Pedestal is a replacement for Ring however from all the examples I see that Pedestal actually uses Ring. This is most confusing! Do I need to know and understand how Ring works in order to use Pedestal effectively. In…
Zuriar
  • 11,096
  • 20
  • 57
  • 92
6
votes
6 answers

Clojure Compojure Ring and https

I'm using Clojure (ring and compojure) to build a web app and I don't know where to start with https. I have a registration and login that will need to be secured, then once they're authenticated they'll need to stay in https. I can't seem to find…
user3866249
  • 61
  • 1
  • 2
6
votes
1 answer

How to handle session in Clojure web application tests written with ring-mock?

In my application, I need a functionality where one request fetches a token(random string) from the server which is stored in the session and the second request is made with this token. When I make the requests in my tests using ring-mock, the…
Devasia Joseph
  • 388
  • 4
  • 14
6
votes
1 answer

Setup and use a cookie-based session in Pedestal

I'd appreciate a basic Pedestal example of how to (1) setup cookies that survive server restarts and (2) use cookie-based sessions; in particular how to get and set values. I'm a little surprised not to find an example that uses…
David J.
  • 31,569
  • 22
  • 122
  • 174