duct

erwinrooijakkers 2020-04-17T16:52:44.034Z

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"}}

erwinrooijakkers 2020-04-17T16:53:23.035Z

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))))

erwinrooijakkers 2020-04-17T16:53:47.035600Z

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

erwinrooijakkers 2020-04-17T16:53:51.035900Z

Any idea why?

kwrooijen 2020-04-17T16:57:01.036300Z

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

erwinrooijakkers 2020-04-17T16:57:07.036500Z

Haha

erwinrooijakkers 2020-04-17T17:01:28.036800Z

Same result

kwrooijen 2020-04-17T17:08:20.037Z

Oh

kwrooijen 2020-04-17T17:08:34.037300Z

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

erwinrooijakkers 2020-04-17T17:09:27.037600Z

Ah moving it to the base profile fixed the problem

erwinrooijakkers 2020-04-17T17:09:32.037900Z

Thanks! 😄

kwrooijen 2020-04-17T17:09:39.038100Z

👍

kwrooijen 2020-04-17T17:11:36.039600Z

@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?

erwinrooijakkers 2020-04-17T17:38:41.040400Z

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

erwinrooijakkers 2020-04-17T17:38:49.040600Z

Any suggestions?

erwinrooijakkers 2020-04-17T17:39:49.041300Z

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)}})

kwrooijen 2020-04-17T17:40:23.041900Z

Your handler seems to have two functions instead of 1?

erwinrooijakkers 2020-04-17T17:43:09.042200Z

Just returns a map

kwrooijen 2020-04-17T17:43:55.042300Z

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

erwinrooijakkers 2020-04-17T17:44:14.042800Z

Ahhh

erwinrooijakkers 2020-04-17T17:53:48.043100Z

Works. Thanks!!! 😆

kwrooijen 2020-04-17T17:54:03.043300Z

😄