This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-07-17
Channels
- # beginners (42)
- # cider (1)
- # cljs-dev (20)
- # clojure (73)
- # clojure-italy (8)
- # clojure-nl (53)
- # clojure-spec (11)
- # clojure-uk (88)
- # clojurescript (170)
- # clojutre (6)
- # core-async (26)
- # css (2)
- # cursive (13)
- # data-science (10)
- # datomic (15)
- # editors (3)
- # figwheel (28)
- # figwheel-main (67)
- # fulcro (57)
- # graphql (2)
- # immutant (2)
- # jobs (1)
- # jvm (4)
- # lein-figwheel (3)
- # leiningen (1)
- # off-topic (5)
- # pedestal (28)
- # re-frame (86)
- # reagent (18)
- # reitit (8)
- # ring (3)
- # ring-swagger (2)
- # shadow-cljs (78)
- # spacemacs (10)
- # specter (12)
- # tools-deps (32)
- # vim (3)
I have one route where I want to skip the secure-headers
default interceptor, but for all the others, I want to use the default interceptors.
is it possible for an interceptor to remove another interceptor from the execution queue? (or in this case, just the :leave
function)
Hi all, what might cause the error?
clojure.lang.ExceptionInfo: java.lang.ClassCastException in Interceptor :io.pedestal.http.secure-headers/secure-headers - java.lang.Integer cannot be cast to clojure.lang.Associative at clojure.core$ex_info.invokeStatic(core.clj:4739) at clojure.core$ex_info.invoke(core.clj:4739) at io.pedestal.interceptor.chain$throwable__GT_ex_info.invokeStatic(chain.clj:35) at io.pedestal.interceptor.chain$throwable__GT_ex_info.invoke(chain.clj:32) at io.pedestal.interceptor.chain$try_f.invokeStatic(chain.clj:57) at io.pedestal.interceptor.chain$try_f.invoke(chain.clj:44) at io.pedestal.interceptor.chain$leave_all_with_binding.invokeStatic(chain.clj:254) at io.pedestal.interceptor.chain$leave_all_with_binding.invoke(chain.clj:237) at io.pedestal.interceptor.chain$leave_all$fn__10637.invoke(chain.clj:268) at clojure.lang.AFn.applyToHelper(AFn.java:152) at clojure.lang.AFn.applyTo(AFn.java:144)
@jm301 If you just need uni-directional data flow from server => client and can settle for http posts on client => server then the SSE work done with pedestal is REALLY high quality. It even lets you pick up where you left off if you’re streaming ordered data by providing an identifier for the last payload you received.
@zhoumin79 Looks like you’re using an integer somewhere that secure-headers is expecting a hashmap
(def csp-header (sec-headers/content-security-policy-header {:default-src “‘self’” :font-src “‘self’ https://at.alicdn.com” :connect-src “‘self’ <ws://localhost:3449/>” :style-src “‘self’ ‘unsafe-inline’” :object-src “‘none’” :script-src “‘self’ ‘unsafe-inline’ ‘unsafe-eval’ https: http:“})) ;; Consumed by xlight.server/create-server ;; See http/default-interceptors for additional options you can configure (def service {:env :prod ::http/routes routes ::http/type :jetty ::http/port 8080 ::http/resource-path “/public” ;::http/allowed-origins {:creds true :allowed-origins (constantly true)} ;::http/allowed-origins [“*”] ;; Content Security Policy (CSP) is mostly turned off in dev mode ::http/secure-headers {:content-security-policy-settings csp-header} ::http/container-options {:h2c? true :h2? false :read-only? false ;:keystore “test/hp/keystore.jks” ;:key-password “password” ;:ssl-port 8443 :ssl? false} })
@joe.lane my secure-headers config, when I delete an item,it triggers this error. Wrong config?
(reg-event-fx :delete-user (fn [ [ user-id]] {:http {:method DELETE :url (str “/users/” (clj->js user-id)) :ignore-response-body true :success-event [:navigate-to-home-page]}}))
The user deleted.But it shows the above error and this
INFO i.p.http.impl.servlet-interceptor - {:msg “sending error”, :message “Internal server error: exception”, :line 215}
;(db/delete-user {:userid 778}) (defn delete-user [request] (let [id (get-in request [:path-params :id])] (db/delete-user {:userid (Integer/parseInt id)})))
Do anyone have a clue? Thanks.
[io.pedestal/pedestal.service “0.5.4”] [io.pedestal/pedestal.jetty “0.5.4"]
lein run--- prod mode
The result from your delete-user
function is likely the number of rows affected as a count correct? The result from delete-user
must be a map.
Its getting mad because the csp leave handler happens to be trying to call functions on the result of delete-user, which is an integer.
@joe.lane thank you very much. I see.
(http/json-response (db/delete-user {:userid id}))
Did that end up workin for you @zhoumin79?
Yes.Thanks.