Releases: kemalcr/kemal
Releases · kemalcr/kemal
v0.18.3
v0.18.2
- Fix Gzip in Kemal Seems broken for static files. This was caused by
Gzip::Writer
inCrystal 0.21.0
and currently mitigated by monkey patchingGzip::Header
.
v0.18.1
- Crystal 0.21.0 support
- Drop
multipart.cr
dependency.multipart
support is now built-into Crystal <3 - Since Crystal 0.21.0 comes built-in with
multipart
there are some improvements and deprecations.
meta
has been removed from FileUpload
and it has the following properties
tmpfile
: This is temporary file for file upload. Useful for saving the upload file.filename
: File name of the file upload. (logo.png, images.zip e.g)headers
: Headers for the file upload.creation_time
: Creation time of the file upload.modification_time
: Last Modification time of the file upload.read_time
: Read time of the file upload.size
: Size of the file upload.
v0.18.0
- Simpler file upload. File uploads can now be accessed from
HTTP::Server::Context
likeenv.params.files["filename"]
.
env.params.files["filename"]
has 5 methods
tmpfile
: This is temporary file for file upload. Useful for saving the upload file.tmpfile_path
: File path oftmpfile
.filename
: File name of the file upload. (logo.png, images.zip e.g)meta
: Meta information for the file upload.headers
: Headers for the file upload.
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
- RF7233 support a.k.a file streaming. (#299) (thanks @denysvitali)
- Update Radix to 0.3.7. Fixes #293
- Configurable startup / shutdown logging. #291 and #292 (thanks @twisterghost).
v0.17.5
v0.17.4
v0.17.3
v0.17.2
v0.17.1
v0.17.0
- 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
ashalt
. - Route declaration must start with
/
. Fixes #242 - Set default exception Content-Type to text/html. Fixes #202
- Add
only
andexclude
paths forKemal::Handler
. This change requires that all handlers must inherit fromKemal::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
tov0.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
tov0.1.1