On 9 June 2015 at 23:16, Dru Sellers <[email protected]> wrote:
> @James do you only have one component that has all of your routes? or do
> you have each component supply its own routes? If you imagine a component
> providing its own routes, I'd love to see a duct example with two routes
> set up.
>
> I believe that would be multiple endpoint components.
>
> Looking at
> https://github.com/weavejester/duct/blob/master/duct/src/duct/component/endpoint.clj#L7
> I'm guessing that duct only expects one endpoint-component - is that
> correct?
>
No, you can have as many endpoint components as you want.
Duct has a handler component that looks for endpoint components in its
dependencies, and combines their routes together using
compojure.core/routes.
One of the ideas in Duct is to group routes together by purpose, to achieve
the modularity of micro-service architecture without the overhead.
For example, let's say you have endpoints foo, bar and baz. Then your
system builder in Duct would look like:
(defn new-system [config]
(let [config (meta-merge base-config config)]
(-> (component/system-map
:http (jetty-server (:http config))
:app (handler-component (:app config))
:foo (endpoint-component foo-endpoint)
:bar (endpoint-component bar-endpoint)
:baz (endpoint-component baz-endpoint))
(component/system-using
{:http [:app]
:app [:foo :bar :baz]}))))
- James
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.