duct-framework / module.ataraxy

Duct module and router for the Ataraxy routing library
5 stars 4 forks source link

Being explicit & switching off infering keys for handlers/middlewares #5

Open RickMoynihan opened 6 years ago

RickMoynihan commented 6 years ago

I wonder if it might be possible to add an option e.g. :fully-qualified-keys true to turn key inference off in the ataraxy router config.

The reason I'd like this is when refactoring things you want to do a find/replace on the keys throughout the project, but because the keys in the router config are aliased, they get missed. Recently I was helping a new developer get up to speed and they'd done this, but this key got missed, and I found myself having to explain this, as an extra unintuitive convention, in addition to clojure's :: prefix and aliases via :as, as things to watch out for.

weavejester commented 6 years ago

I've been considering a redesign of this module, but I'm not entirely sure how.

It's worth mentioning that you can just use the router on its own. It's a little more verbose, but it does have the advantage of no key inference.

RickMoynihan commented 6 years ago

Just to say I've run into another limitation because of this. You can't use this module with handlers and integrant composite keys.

e.g.

 :duct.module/ataraxy {
                       "/foo" {["" #{blah}] [[:composite-handler/foo :foo/bar]
                                             blah]}
}
weavejester commented 6 years ago

You can add a unique key to your composite key, and use that instead:

{:duct.core/project-ns example
 :duct.module/ataraxy {["/foo" #{blah}] [:foo blah]}
 [:composite-handler/foo :foo/bar :example.handler/foo] {}}