compojure

Using a javax.servlet.Filter with Compojure

假如想象 提交于 2019-12-18 11:59:25
问题 I'm trying to build a simple web site using Clojure / Compojure and want to feed apply a servlet filter to the request / response (i.e. a standard javax.servlet.Filter instance). e.g. if the current source code is: (defroutes my-app (GET "/*" (html [:h1 "Hello Foo!!"])) ) I would like to add a filter like this: (defroutes my-app (GET "/*" (FILTER my-filter-name (html [:h1 "Hello Foo!!"]))) ) Where my-filter-name is some arbitrary instance of javax.servlet.Filter. Any idea how to do this

How to run/debug compojure web app via counterclockwise (or la clojure)

拥有回忆 提交于 2019-12-13 13:01:17
问题 I'm trying to write my first web app in compojure. I'm using ccw, and I File-New-Project, Clojure Project and use the "compojure" leiningen template. End up with project.clj looking like (defproject asdf "0.1.0-SNAPSHOT" :description "FIXME: write description" :url "http://example.com/FIXME" :dependencies [[org.clojure/clojure "1.4.0"] [compojure "1.1.5"]] :plugins [[lein-ring "0.8.2"]] :ring {:handler asdf.handler/app} :profiles {:dev {:dependencies [[ring-mock "0.1.3"]]}}) src/asdf/handler

Friend authentication empty param

北城以北 提交于 2019-12-13 03:36:49
问题 I am trying to implement friend authentication on my web app but when i try to login i get this */login?&login_failed=Y&username=*...my param is empty and i cant login,what am i doing wrong? these are my routes... (defroutes routes (GET "/" [] (index)) (GET "/indexMessage" [] (indexMessage)) (GET "/login" req (index)) (POST "/insert-user" {params :params} (let [firstname (get params "firstname") lastname (get params "lastname") email (get params "email") password (get params "password") sex

with-redefs doesn't redefine my function

允我心安 提交于 2019-12-12 03:15:20
问题 I have a test: (ns gui-proxy.handler-test (:require [clojure.test :refer :all] [ring.mock.request :as mock] [gui-proxy.handler :as handler])) (deftest test-app (testing "not-found route" (with-redefs-fn [handler/log-request (fn [type url] (str ""))] (let [response (handler/app (mock/request :get "/invalid"))] (is (= (:status response) 404)))))) and the code that are under test: (ns gui-proxy.handler (:require [compojure.core :refer :all] [compojure.route :as route] [ring.middleware.defaults

Why is username not saved in noir session in Clojure project?

浪尽此生 提交于 2019-12-11 15:45:21
问题 This is how I save it during login: (defn set-loggedin [username] (sesh/put! :username username)) (defn login-handler [username password] (let [user (datab/login username password)] (if (empty? user) (view/login-form "Wrong password.") (do (set-loggedin username) (resp/redirect "/movies"))))) (defroutes app-routes ... (POST "/" [username password] (login-handler username password)) (POST "/movie/save" [movieID name] (film-new movieID name)) ...) (def app (noir-middleware/app-handler [app

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

add unique id to requests forwarded from nginx reverse proxy

情到浓时终转凉″ 提交于 2019-12-10 22:47:18
问题 We are running nginx as a reverse proxy that forwards requests to a Clojure application running Compojure, a library that wraps around Jetty and provides our application with the ability to service web requests. We currently capture logs generated by both nginx and the Clojure application (via log4j to syslog). We are unable, however, to match an entry in the nginx log to an entry in the syslog output of the Clojure application. We need to figure out a way to modify the request sent upstream

Serving index.html file from compojure

巧了我就是萌 提交于 2019-12-10 19:03:11
问题 I'm new to clojure and compojure and trying out the compojure along with ring to create a basic web application. here is my handler.clj (ns gitrepos.handler (:require [compojure.core :refer :all] [compojure.route :as route] [ring.util.response :as resp] [ring.middleware.defaults :refer [wrap-defaults site-defaults]])) (defroutes app-routes (GET "/" [] (resp/file-response "index.html" {:root "public"})) (route/not-found "Not Found")) (def app (wrap-defaults app-routes site-defaults)) i have