Skip to content

v0.17.0

Compare
Choose a tag to compare
@sdogruyol sdogruyol released this 23 Nov 17:49
· 316 commits to master since this release
  • Reimplemented Request middleware / filter routing.

Now all requests will first go through the Middleware stack then Filters (before_*) and will finally reach the matching route.

Which is illustrated as,

Request -> Middleware -> Filter -> Route
  • Rename return_with as halt.
  • Route declaration must start with /. Fixes #242
  • Set default exception Content-Type to text/html. Fixes #202
  • Add only and exclude paths for Kemal::Handler. This change requires that all handlers must inherit from Kemal::Handler.

For example this handler will only work on / path. By default the HTTP method is GET.

OnlyHandler < Kemal::Handler
  only ["/"]

  def call(env)
    return call_next(env) unless only_match?(env)
    puts "If the path is / i will be doing some processing here."
  end
end

The handlers using exclude will work on the paths that isn't specified. For example this handler will work on any routes other than /.

ExcludeHandler < Kemal::Handler
  exclude ["/"]

  def call(env)
    return call_next(env) unless only_match?(env)
    puts "If the path is NOT / i will be doing some processing here."
  end
end
  • Close response on halt. (thanks @samueleaton).
  • Update Radix to v0.3.4.
  • error handler now also yields error. For example you can get the error mesasage like
  error 500 do |env, err|
    err.message
  end
  • Update multipart.cr to v0.1.1