ring

Midje provided not stubbing function in Compojure / Ring handler

自作多情 提交于 2019-12-11 11:04:09
问题 I'm attempting to use Midje to stub the view in a handler unit test, but my use of Midje's (provided) obviously isn't correct. I've simplified and inlined the view to a (content) function in the handler: (ns whattodo.handler (:use compojure.core) (:require [whattodo.views :as views])) (defn content [] (views/index)) (defn index [] (content)) (defroutes app (GET "/" [] (index))) and am trying to test it using (ns whattodo.t-handler (:use midje.sweet) (:use ring.mock.request) (:use whattodo

How to use compojure from Intellij

隐身守侯 提交于 2019-12-11 05:47:16
问题 I've spent more time that I want to admit trying to compile and run a compojure app from intellij. From the command line I use lein ring server-headless. If I run from inside intellij the REPL begins and I can't call or start the server from inside the REPL. How can I compile and run a server from inside the REPL? 回答1: You want to run the server from inside the repl? Add [ring/ring-jetty-adapter "1.3.1"] as a dependency In the REPL: (require 'ring.adapter.jetty) (require 'quals.core.handler)

How to include css files into compojure project?

孤者浪人 提交于 2019-12-11 02:58:43
问题 I'm learning clojure and I work on project where I'm using compojure & ring & clostache (mustache for clojure) . This is my core clojure file: (defroutes public-routes (GET "/" [] (controller/index)) (route/resources "/") (GET "/index" [] (controller/index)) (route/resources "/") (GET "/customers" [] (controller/customers)) (route/resources "/") (GET "/employees" [] (controller/employees)) (route/resources "/") ) (defroutes app-routes public-routes (route/not-found "404 Not Found") ) My

Accessing posted json with ring format-params middleware

空扰寡人 提交于 2019-12-10 23:31:10
问题 I'm trying to make a very simple API using ring in clojure. I'm using the rack.middleware.format-params middleware to convert the output to json, and the input from json to clojure data structures. I've got the output working nicely, but I can't for the life of me access the parameters sent through json. Here's some code that works for get requests, but I can't get the POST request to return the json it recieves (ns testing.core (:use [compojure.core] [ring.middleware.format-params :only

Add webapp frontend to existing clojure app

守給你的承諾、 提交于 2019-12-10 19:55:48
问题 I have a Clojure-based chat bot that I start up in typical leiningen fashion with lein run . I'd like to add a front end to this app, but not totally sure how to go about it. From reading docs on compojure, lib-noir and ring, looks like the standard way to serve is with lein ring server . I'd rather just start up the app and the front end with a single lein command if possible. Would this involve manually starting up the server (in another thread perhaps) with something like (run-jetty

ring.middleware and compojure: params with keywords

感情迁移 提交于 2019-12-10 17:45:06
问题 In my web handler, I have the following defined: (:require ... [ring.middleware.cookies :refer [wrap-cookies]] [ring.middleware.multipart-params :refer [wrap-multipart-params]] [ring.middleware.params :refer [wrap-params]] [ring.middleware.keyword-params :refer [wrap-keyword-params]] [ring.middleware.content-type :refer [wrap-content-type]] [ring.middleware.format-response :refer [wrap-restful-response] ...) (def app (-> (routes home/my-routes) (wrap-cookies) (wrap-params) (wrap-multipart

lein ring server-headless - only listen to localhost?

。_饼干妹妹 提交于 2019-12-10 15:16:00
问题 I have a Clojure project using lein-ring and the compojure web framework, which I start using the lein ring server-headless command. It produces the following output: 2014-06-28 19:37:50.236:INFO:oejs.Server:jetty-7.6.8.v20121106 2014-06-28 19:37:50.315:INFO:oejs.AbstractConnector:Started SelectChannelConnector@0.0.0.0:3000 Started server on port 3000 I kind of just realized that this is listening on 0.0.0.0 . A netstat -nltp confirms this: tcp6 0 0 :::3000 :::* LISTEN 31781/java Is it

Using Compojure, Hiccup and Ring to upload MULTIPLE files

亡梦爱人 提交于 2019-12-10 14:32:33
问题 This is really a rip off of Using Compojure, Hiccup and Ring to upload a file If there is a multiple tag: <form action="/file" method="post" enctype="multipart/form-data"> <input name="file" type="file" size="20" multiple/> <input type="submit" name="submit" value="submit" /> How would one go about getting the values of all the files using ring? 回答1: I created a test project and checked what sort of data the request map contains when arriving to the back-end when submitting multiple files.

how do i mock a json post request in ring?

醉酒当歌 提交于 2019-12-08 19:23:09
问题 I'm using peridot - https://github.com/xeqi/peridot to test my ring application, and its working fine until I try to mock a post request with json data: (require '[cheshire.core :as json]) (use 'compojure.core) (defn json-post [req] (if (:body req) (json/parse-string (slurp (:body req))))) (defroutes all-routes (POST "/test/json" req (json-response (json-post req)))) (def app (compojure.handler/site all-routes)) (use 'peridot.core) (-> (session app) (request "/test/json" :request-method :post

How can I add a build step to leiningen?

岁酱吖の 提交于 2019-12-07 11:20:51
问题 So I've got an application built using Foundation and Ring, and I want to be able to compile my custom Foundation CSS whenever I run lein ring server or the like. Specifically, I'd like to be able to add a step the runs compass compile [path] . What's the idiomatic way to do this? 回答1: I would say, Leiningen Hooks are the proper and idiomatic way to do so: Hooks. You can modify the behaviour of built-in tasks to a degree using hooks. Hook functionality is provided by the Robert Hooke library,