This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-01
Channels
- # beginners (133)
- # boot (59)
- # cider (5)
- # cljs-dev (30)
- # cljsrn (23)
- # clojure (212)
- # clojure-austin (3)
- # clojure-brasil (1)
- # clojure-chicago (5)
- # clojure-italy (10)
- # clojure-russia (5)
- # clojure-serbia (1)
- # clojure-spec (34)
- # clojure-turkiye (2)
- # clojure-uk (132)
- # clojurescript (163)
- # clojutre (1)
- # cursive (5)
- # datomic (58)
- # emacs (42)
- # events (1)
- # graphql (26)
- # hoplon (16)
- # jobs (1)
- # lumo (27)
- # numerical-computing (3)
- # off-topic (127)
- # om (9)
- # onyx (24)
- # re-frame (20)
- # reagent (20)
- # ring-swagger (14)
- # sql (19)
- # unrepl (28)
- # untangled (3)
- # vim (8)
- # yada (17)
I have a problem with not-found route using compojure-api and middleware to wrap authentication. The authentication wrapper “eats” all requests and the not-found route is never matched.
(require '[compojure.api.sweet :as api])
(def handler
(api/routes
(api/middleware [auth/wrap-api-authentication]
protected-api-routes)
(route/not-found "Not Found")))
This post describes similar problem with plain compojure that I used to solve with wrap-routes
function http://jakemccrary.com/blog/2014/12/21/restricting-access-to-certain-routes/
Any ideas?@mhautala wrap-middleware
which workslike wrap-routes
is available in 2.0 alpha
Ok, now I noticed that is exactly what it says in the middleware functions documentation
Note that middlewares will be executed even if routes in body
do not match the request uri. Be careful with middlewares that
have side-effects.
@mhautala good solution is to apply authentication for a explicit context. e.g.
(context "/admin-routes" []
:middleware [auth-wrap-api-authentication]
...)
then it only applies for those routes. Can be applied to endpoints & api-level too (with 2.0.0).Ok that’s a good solution, I found already that approach for endpoint level but at context or api-level you can avoid repeating code
I’m getting a persistent eastwood warn with compojure-api
(ns test-eastwood.core
(:require [compojure.api.sweet :refer :all]
[schema.core :as schema]))
(def v1-routes
(routes
(POST "/foo" []
:return {:bar schema/Int}
{:status 200 :body {:bar 35}})))
gives me
== Linting test-eastwood.core ==
Entering directory `/Users/michael.blume/workspace/test-eastwood'
src/test_eastwood/core.clj:1:1: suspicious-expression: merge called with 1 args. (merge map) always returns map. Perhaps there are misplaced parentheses?
both with 1.1.10 and 2.0.0-alpha1
https://github.com/MichaelBlume/eastwood-test if that’s helpful