Skip to content

Releases: kemalcr/kemal

v0.26.1

01 Dec 11:16
Compare
Choose a tag to compare
  • Fix process request when a response already closed #550. Thanks @mamantoha πŸ™
  • Switch to new Ameba repository #549. Thanks @mamantoha πŸ™
  • Check for KEMAL_ENV variable already in Config#initialize#552. Thanks @Sija πŸ™
  • Cleanup Ameba warnings #551. Thanks @Sija πŸ™
  • Flush io buffer after each write to log #554. Thanks @mang πŸ™

v0.26.0

05 Aug 07:51
Compare
Choose a tag to compare

0.25.2

08 Feb 09:04
Compare
Choose a tag to compare
  • Crystal 0.27.2 support πŸŽ‰

  • Add option to config to parse or not command line parameters #483. Thanks @diegogub πŸ™

  • Allow to set filename for send_file #512. Thanks @mamantoha πŸ™

send_file env, "./asset/image.jpeg", filename: "image.jpg"
  • Set status_code before response #513. Thanks @mamantohoa πŸ™

  • Use Crystal MIME registry. #516 Thanks @Sija πŸ™

v0.25.1

05 Nov 20:02
Compare
Choose a tag to compare

v0.25.0

04 Nov 23:31
Compare
Choose a tag to compare
  • Crystal 0.27.0 support.

  • [breaking change] Added back env.params.files.

Here's a fully working sample for reading a image file upload image1 and saving it under public/uploads.

post "/upload" do |env|
file = env.params.files["image1"].tmpfile
file_path = ::File.join [Kemal.config.public_folder, "uploads/", file.filename]
File.open(file_path, "w") do |f|
  IO.copy(file, f)
end
"Upload ok"
end

To test

curl -F "image1=@/Users/serdar/Downloads/kemal.png" http://localhost:3000/upload

  • Cache HTTP routes to increase performance πŸš€ #493

v0.24.0

14 Aug 11:18
Compare
Choose a tag to compare
  • Crystal 0.26.0 support

  • [breaking change] Removed env.params.files. You can use Crystal's built-in HTTP::FormData.parse instead

post "/upload" do |env|
  HTTP::FormData.parse(env.request) do |upload|
    filename = file.filename

    if !filename.is_a?(String)
      "No filename included in upload"
    else
      file_path = ::File.join [Kemal.config.public_folder, "uploads/", filename]
      File.open(file_path, "w") do |f|
      IO.copy(file.tmpfile, f)
    end
    "Upload OK"
  end
end
  • [breaking change] From now on to access dynamic url params in a WebSocket route you have to use:
ws "/:id" do |socket, context|
  id = context.ws_route_lookup.params["id"]
end
  • [breaking change] Removed _method magic param.

  • Added new exception page #466. Thanks @mamantoha πŸ™

  • Support custom port binding. Thanks @straight-shoota πŸ™

Kemal.run do |config|
  server = config.server.not_nil!
  server.bind_tcp "127.0.0.1", 3000, reuse_port: true
  server.bind_tcp "0.0.0.0", 3001, reuse_port: true
end

v0.23.0

17 Jun 16:20
Compare
Choose a tag to compare
  • Crystal 0.25.0 support πŸŽ‰
  • Add Kemal::Context.get? to safely access context storage 😎
  • [Security] Don't serve 404 image dynamically πŸ‘
  • Disable X-Powered-By header #449. Thanks @Blacksmoke16 πŸ™

v0.22.0

29 Dec 12:39
Compare
Choose a tag to compare
  • Crystal 0.24.1 support πŸŽ‰
  • Only return string from route.#408 thanks @crisward πŸ™
  • Don't crash on empty path when compiled in --release. #407 thanks @crisward πŸ™
  • Rename Kemal::CommonLogHandler to Kemal::LogHandler and Kemal::CommonExceptionHandler to Kemal::ExceptionHandler.
  • Allow videos to be opened with correct mime type. #406 thanks @crisward πŸ™
  • Add webm mime type.#413 thanks @reindeer-cafe πŸ™

v0.21.0

05 Sep 11:09
Compare
Choose a tag to compare
  • Dynamically insert handlers πŸ’ͺ Fixes #376.
  • Add context to WebSocket. This allows one to use HTTP::Server::Context in ws declarations 😍 Fixes #349.
ws "/:room_name" do |socket, env|
  env.params.url["room_name"]
end
  • Add support for customizing the headers of built-in Kemal::StaticFileHandler πŸ”¨ Useful for supporting CORS for single page applications πŸ‘
static_headers do |response, filepath, filestat|
  if filepath =~ /\.html$/
      response.headers.add("Access-Control-Allow-Origin", "*")
    end
    response.headers.add("Content-Size", filestat.size.to_s)
  end
end

v0.20.0

01 Jul 19:15
Compare
Choose a tag to compare
  • Crystal 0.23.0 support! As always, Kemal is compatible with the latest major release of Crystal πŸ’Ž
  • Great news everyone πŸŽ‰ All handlers are now completely customizable!. Use the default Kemal handlers or go wild, it's all up to you ⛏
# Don't forget to add `Kemal::RouteHandler::INSTANCE` or your routes won't work!
Kemal.config.handlers = [Kemal::InitHandler.new, YourHandler.new, Kemal::RouteHandler::INSTANCE]

You can also insert a handler into a specific position.

# This adds MyCustomHandler instance to 1 position. Be aware that the index starts from 0.
add_handler MyCustomHandler.new, 1
  • Updated Kilt to v0.4.0.
  • Make Route a Struct. This improves the performance of route declarations.