5.8 KiB
0.18.1 (21-02-2016)
- Crystal 0.21.0 support
- Drop
multipart.crdependency.multipartsupport is now built-into Crystal <3 - Since Crystal 0.21.0 comes built-in with
multipartthere 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.
0.18.0 (11-02-2016)
- Simpler file upload. File uploads can now be access from
HTTP::Server::Contextlikeenv.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. (https://github.com/kemalcr/kemal/pull/299) (thanks @denysvitali)
-
Update Radix to 0.3.7. Fixes https://github.com/kemalcr/kemal/issues/293
-
Configurable startup / shutdown logging. https://github.com/kemalcr/kemal/issues/291 and https://github.com/kemalcr/kemal/issues/292 (thanks @twisterghost).
0.17.5 (09-01-2016)
- Update multipart.cr to 0.1.2. Fixes #285 related to multipart.cr
0.17.4 (24-12-2016)
- Support for Crystal 0.20.3
- Add
Kemal.stop. Fixes #269. HTTP::Handleris not a class anymore, it's a module. See https://github.com/crystal-lang/crystal/releases/tag/0.20.3
0.17.3 (03-12-2016)
- Handle missing 404 image. Fixes #263
- Remove basic auth middleware from core and move to kemalcr/kemal-basic-auth.
0.17.2 (25-11-2016)
- Use body.gets_to_end for parse_json. Fixes #260.
- Update Radix to 0.3.5 and lock pessimistically. (thanks @luislavena)
0.17.1 (24-11-2016)
- Treat
HTTP::Requestbody as anIO. Fixes #257
0.17.0 (23-11-2016)
- 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_withashalt. - Route declaration must start with
/. Fixes #242 - Set default exception Content-Type to text/html. Fixes #202
- Add
onlyandexcludepaths 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.
class 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 /.
class 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
Radixtov0.3.4. errorhandler now also yields error. For example you can get the error mesasage like
error 500 do |env, err|
err.message
end
- Update
multipart.crtov0.1.1
0.16.1 (12-10-2016)
- Improved Multipart support with more info on parsed files.
parse_multipart(env)now yields anUploadFileobject which has the following propertiesfield,data,meta,`headers.
post "/upload" do |env|
parse_multipart(env) do |f|
image1 = f.data if f.field == "image1"
image2 = f.data if f.field == "image2"
puts f.meta
puts f.headers
"Upload complete"
end
end
0.16.0
- Multipart support <3 (thanks @RX14). Now you can handle file uploads.
post "/upload" do |env|
parse_multipart(env) do |field, data|
image1 = data if field == "image1"
image2 = data if field == "image2"
"Upload complete"
end
end
- Make session configurable. Now you can specify session name and expire time wit
Kemal.config.session["name"] = "your_app"
Kemal.config.session["expire_time"] = 48.hours
- Session now supports more types. (String, Int32, Float64, Bool)
- Add
gziphelper to enable / disable gzip compression on responses. - Static file caching with etag and gzip (thanks @crisward)
Kemal.runnow accepts port to listen.
0.15.1 (05-09-2016)
- Don't forget to call_next on NullLogHandler
0.15.0 (03-09-2016)
- Add context store
KEMAL_ENVrespects toKemal.config.envand needs to be explicitly set.Kemal::InitHandleris introduced. Adds initial configuration, headers likeX-Powered-By.- Add
send_fileto helpers. - Add mime types.
- Fix parsing JSON params when "charset" is present in "Content-Type" header.
- Use http-only cookie for session
- Inject STDOUT by default in CommonLogHandler