Providing default implementations - a design problem with protocols

I tend to agree on both counts, I definitely didn’t want config in my app code, and settled for keeping it in one place in my app code, the router, because the router is the closest to config already. You have your resources, you are essentially configuring how to expose them to the endpoint.

Now that I am thinking about it, I am wondering whether extending the router DSL would have been better, so you could do something like this:

live_admin "/admin" do
  admin_resource "/staff", User, opts
  admin_resource "/posts", Post, opts
end

Arguably just as much config in the router, but it would be more…“routerish” config

1 Like