Fork me on GitHub
#duct
<
2020-04-17
>
erwinrooijakkers16:04:44

I have the following routes:

{:duct.profile/base {:duct.core/project-ns logout
                     :duct.router/ataraxy
                     {:routes {"/v1/logout" [:logout]}
                      :handlers {:logout #ig/ref :my-app/logout}}
                     :duct.logger/clojure {}}
 :duct.profile/dev #duct/include "dev"
 :duct.profile/local #duct/include "local"
 :duct.profile/prod {}
 :duct.module.web/api {}
 :my-app/logout {:env/deployment-env #duct/env "DEPLOYMENT_ENV"}}

erwinrooijakkers16:04:23

and in ns my-app the following init-key:

(defmethod ig/init-key :my-app/logout
  [_ {:env/keys [deployment-env] :as _opts}]
  (log/info ::logout.init {:deployment-env deployment-env})
  (fn [_handler]
    (fn [request]
      (log/debug ::logout {:request request})
      (create-logout-response deployment-env))))

erwinrooijakkers16:04:47

When I start the system with lein repl (dev) (go) I get:

Execution error (IllegalArgumentException) at integrant.core/load-namespaces (core.cljc:182).
Don't know how to create ISeq from: my-app.logout$eval18600$fn__18602$fn__18604$fn__18605

kwrooijen16:04:01

I think it should be :routes {"/v1/logout" [:my-app/logout]} . And remove the :handlers key

kwrooijen17:04:34

:my-app/logout is outside of the base profile

erwinrooijakkers17:04:27

Ah moving it to the base profile fixed the problem

kwrooijen17:04:36

@weavejester This PR is still open, regarding adding a specific error message for when a regular key is added outside of the base profile https://github.com/duct-framework/core/pull/32 Maybe we can get this merged to prevent this in the future?

erwinrooijakkers17:04:41

Error when calling the endpoint is: java.lang.ClassCastException my-app.logout$eval25212$fn__25214$fn__25216$fn__25217 cannot be cast to clojure.lang.Associative

erwinrooijakkers17:04:49

Any suggestions?

erwinrooijakkers17:04:49

create-logout-response :

(defn- create-logout-response [deployment-env]
  {:status see-other-status-code
   :headers {"location" (create-keycloak-logout-url deployment-env)
             "set-cookie" (create-expired-keycloak-cookies deployment-env)}})

kwrooijen17:04:23

Your handler seems to have two functions instead of 1?

erwinrooijakkers17:04:09

Just returns a map

kwrooijen17:04:55

I meant this: The (fn [_handler] should be removed

erwinrooijakkers17:04:48

Works. Thanks!!! 😆