Search code examples
crystal-langkemal

Kemal configuration using blocks


Kemal currently allows setting configuration options via:

Kemal.config.env = "development" Kemal.config.port = "3456"

I want to do something like with a block:

configuration do |config| config.env = "development" config.port = "3456" ... end

Is this even possible?
Thanks for any insights.


Solution

  • I believe, you could utilize Object#tap method like this:

    Kemal.config.tap do |config|
      config.env = "development"
      config.port = "3456"
      ...
    end