HI guys, just started learning duct ( although i use integrant in the front end for a framework i am building ).
I have used luminus for a backend so familiar with the main ring / compojure ecosystem.
So, a possibly stupid question, but i have found no examples to orient myself ...
how would i implement cors when using :duct.module.web/api
or :duct.router/cascading
?
any direction would be appreciated. cheers
@clojurians827 I think it is happening because :duct.migrator/ragtime
and [:duct.migrator.ragtime/sql :todo.migration/create-entries]
should be in the base profile
{:duct.profile/base
{:duct.core/project-ns todo
:duct.router/ataraxy
{:routes {[:get "/"] [:todo.handler/index]}
:handlers {:todo.handler/index #ig/ref :todo.handler/index}}
[:duct.handler.static/ok :todo.handler/index]
{:body {:entries "/entries"}}
:duct.migrator/ragtime
{:migrations [#ig/ref :todo.migration/create-entries]}
[:duct.migrator.ragtime/sql :todo.migration/create-entries]
{:up ["CREATE TABLE entries (id INTEGER PRIMARY KEY, content TEXT)"]
:down ["DROP TABLE entries"]}}
:duct.profile/dev #duct/include "dev"
:duct.profile/local #duct/include "local"
:duct.profile/prod {}
:duct.module/logging {}
:duct.module.web/api {}
:duct.module/sql {}}
Like this
@fj.abanses you should learn about middleware for :duct.core/handler
. Look to https://github.com/duct-framework/core#keys about :duct.core/handler
. But note https://github.com/duct-framework/module.web/blob/47a07008d42a349e77131ee35fe552b9f67e3a1a/CHANGELOG.md#070-alpha3-2018-09-28
For example it might look like
:duct.handler/root
{:middleware [#ig/ref :your.middleware/cors]} ;; middleware will be appended by default
:your.middleware/cors {}
Also look into https://github.com/duct-framework/core/blob/04f5378f4a8d73af4f208c5f5e8125d53506fbd9/src/duct/core.clj#L81