Today, I am very pleased to announce the release of Crest
version 0.10
!
Another Crystal HTTP library? Why should I care?
Beloved features:
- Redirects support.
- HTTP(S) proxy support.
- Elegant Key/Value headers, cookies, params, and payload.
- Multipart file uploads.
- Logging.
Hopefully, someday I can remove this shard though. Ideally, Crystal's standard library would do all this already.
More info you can find on the project page: https://github.com/mamantoha/crest
New capabilities of version 0.10
include:
Crest
and Crest::Request
verb methods(get
, post
, etc.) can yields the Crest::Request
to the block.
response = Crest::Request.get("http://example.com") do |request|
request.headers.add("foo", "bar")
end
Crest::Request
and Crest::Resource
initializer can accept the instance of HTTP::Client
via http_client
method.
This is useful for unusual cases when you want to set additional options (e.g. read timeout, authorization header etc.).
client = HTTP::Client.new("http://example.com")
client.read_timeout = 1.second
begin
Crest::Request.new(:get,
"http://example.com/delay",
http_client: client
)
rescue IO::Timeout
puts "Timeout!"
end