compojure

How do I add CORS to a compojure-api app?

你离开我真会死。 提交于 2021-02-09 09:40:16
问题 How can I add CORS to this code snippet? (def app (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "/route-c" [] "c"))) I would like to use https://github.com/r0man/ring-cors and have tried this, but it did not seem to do anything. I would like to see the response header contain Access-Control-Allow-Origin but it is missing. (-> (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "

How do I add CORS to a compojure-api app?

大憨熊 提交于 2021-02-09 09:36:17
问题 How can I add CORS to this code snippet? (def app (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "/route-c" [] "c"))) I would like to use https://github.com/r0man/ring-cors and have tried this, but it did not seem to do anything. I would like to see the response header contain Access-Control-Allow-Origin but it is missing. (-> (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "

How do I add CORS to a compojure-api app?

邮差的信 提交于 2021-02-09 09:36:16
问题 How can I add CORS to this code snippet? (def app (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "/route-c" [] "c"))) I would like to use https://github.com/r0man/ring-cors and have tried this, but it did not seem to do anything. I would like to see the response header contain Access-Control-Allow-Origin but it is missing. (-> (api {:swagger {:ui "/docs" :spec "/swagger.json"}} (GET "/route-a" [] "a") (GET "/route-b" [] "b") (GET "

Invalid anti-forgery token

时光总嘲笑我的痴心妄想 提交于 2021-02-07 13:35:40
问题 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 coming from other sites (to use someone else's credentials who has already logged in and access pages not allowed to access). These tokens are default, and we need to use ring.middleware 's wrap-params around our WebApp. Couldn't get anywhere much.

Clojure warning: “resultset-seq already exists in clojure.core”

对着背影说爱祢 提交于 2021-01-27 08:10:57
问题 I'm new to Clojure and building a web app using the Noir framework (very similar to Compojure, in fact I think it's Compojure with a different request handler layer). I'm getting a warning when I import the JDBC library: WARNING: resultset-seq already refers to: #'clojure.core/resultset-seq in namespace: webapp.models.database, being replaced by: #'clojure.java.jdbc/resultset-seq Do I have to live with this warning or is there a way around it? I'm importing the JDBC library using: (use

Clojure warning: “resultset-seq already exists in clojure.core”

两盒软妹~` 提交于 2021-01-27 08:10:24
问题 I'm new to Clojure and building a web app using the Noir framework (very similar to Compojure, in fact I think it's Compojure with a different request handler layer). I'm getting a warning when I import the JDBC library: WARNING: resultset-seq already refers to: #'clojure.core/resultset-seq in namespace: webapp.models.database, being replaced by: #'clojure.java.jdbc/resultset-seq Do I have to live with this warning or is there a way around it? I'm importing the JDBC library using: (use

How to get all the params of a POST request with Compojure

这一生的挚爱 提交于 2021-01-22 06:59:37
问题 According to the Compojure documentation on routes, I can easily get individual parameters like this: (POST "/my-app" [param1 param2] (str "<h1>Hello " param1 " and " param2 "</h1>")) How do I get all parameters, not just individual parameters? 回答1: compojure handlers receive the entire request map as their argument, so handler has also an access to all of the parameters. For example, to see entire request: (POST "/" request (str request)) or, to extract all form parameters: (POST "/" request

NullPointerException when lein ring server on Aleph+Ring

♀尐吖头ヾ 提交于 2020-06-17 07:38:27
问题 I am trying to run Aleph on top of Ring and use lein ring server for shorter feedback loop. When I'm invoking lein ring server everything seems to be fine but when I point my browser to an url I get a nasty NullPointerException with the stack trace below. However, when I run (al.app/start 3006) then no NLP shows up. The whole project is available on GitHub. What am I doing wrong? core.clj:107 lamina.core/enqueue app.clj:39 al.app/hello-handler http.clj:79 aleph.http/wrap-aleph-handler[fn]

用n多的框架写同一个demo

我只是一个虾纸丫 提交于 2020-02-29 17:27:41
发表日期2016年年末 最近有了比较长的空闲时间。 所以看了很多很多不同的语言,框架。 java用了很多年了,总觉得眼界都被java影响了,所以想从新开始学一点新的东西。 而一旦开始选择开始的路径,完美主义的小心思就出来作祟了。 泛泛的接触了好多好多东西,基本上主流的语言,框架都把入门文档看了个遍。 到最后都没有达到最初想学点东西的目的,反而看文档的能力提高不少...... 所以,我决定不再单纯的看了。 我觉得执行下面的计划,动手写写。这也是为什么文章开始就要写明发表时间,因为未来会发生什么谁也不知道,我得到的结果只是当下我认为的好结果而已。 仅此而已 测试方式:controller层上返回服务器当前时间 new Date().getTime() //long类型 开发方式:使用各个框架的引导教程默认设置去写代码,尽量写最少的代码完成demo 测试的框架:jfinal(java),grails(groovy),play(scala),springboot-undertow(java),express(js),beego(golang),compojure(clojure)....看情况增加 测试内容:ab进行压测测试,开发效率(完成所花费的时间),上手难度,扩展性(面对需求频繁更改的可维护性) 压测命令:ab -n 100000 -c 1000 -k http:/

Local dependencies in Leiningen without creating a Maven repo?

时光毁灭记忆、已成空白 提交于 2020-01-22 19:28:12
问题 I'm building a Compojure web application, and I'd like it to use functions from another Clojure project I wrote. I'm not at all familiar with Maven, and from what I've heard, it has a very steep learning curve. Unfortunately, everything I've seen suggests using a private Maven repo as a dependency and doesn't suggest an alternative. I'd really like to avoid struggling with Maven if possible. Does anyone know of an alternative? I'm currently using the latest version of Leiningen. 回答1: If the