module Crest
Overview
This module's static methods are the entry point for using the Crest client.
Supported HTTP methods: .get, .put, .post, .patch .delete, .options, .head
Examples:
Crest.get(
"http://httpbin.org/get",
headers: {"Content-Type" => "image/jpg"},
params: {"lang" => "en"}
)
Crest.post(
"http://httpbin.org/post",
headers: {"Access-Token" => ["secret1", "secret2"]},
form: {"fizz" => "buz"},
logging: true,
)
Crest.get("http://httpbin.org/stream/5") do |response|
while line = response.body_io.gets
puts line
end
end
Defined in:
crest.crcrest/curlify.cr
crest/exceptions.cr
crest/form.cr
crest/forms/data_form.cr
crest/forms/json_form.cr
crest/forms/stream_data_form.cr
crest/forms/urlencoded_form.cr
crest/logger.cr
crest/loggers/common_logger.cr
crest/params_decoder.cr
crest/params_encoder.cr
crest/params_encoders/enumerated_flat_params_encoder.cr
crest/params_encoders/flat_params_encoder.cr
crest/params_encoders/nested_params_encoder.cr
crest/params_encoders/zero_enumerated_flat_params_encoder.cr
crest/redirector.cr
crest/request.cr
crest/resource.cr
crest/response.cr
Constant Summary
-
EXCEPTIONS_MAP =
{} of Int32 => Crest::RequestFailed.class -
HTTP_METHODS =
["get", "delete", "post", "put", "patch", "options", "head"] of ::String -
STATUSES =
({} of Int32 => String).tap do |statuses| HTTP::Status.each do |status| if description = status.description statuses[status.code] = description end end end -
Hash of HTTP status code => standard-library description.
-
USER_AGENT =
"Crest/#{Crest::VERSION} (Crystal/#{Crystal::VERSION})" -
VERSION =
{{ (`shards version /home/runner/work/crest/crest/src`).chomp.stringify }}
Class Method Summary
-
.delete(url : String, form = {} of String => String, **args, &block : Crest::Response -> ) : Nil
Execute a DELETE request and and yields the
Crest::Responseto the block. -
.delete(url : String, form = {} of String => String, **args) : Crest::Response
Execute a DELETE request and returns a
Crest::Response. -
.get(url : String, form = {} of String => String, **args, &block : Crest::Response -> ) : Nil
Execute a GET request and and yields the
Crest::Responseto the block. -
.get(url : String, form = {} of String => String, **args) : Crest::Response
Execute a GET request and returns a
Crest::Response. -
.head(url : String, form = {} of String => String, **args, &block : Crest::Response -> ) : Nil
Execute a HEAD request and and yields the
Crest::Responseto the block. -
.head(url : String, form = {} of String => String, **args) : Crest::Response
Execute a HEAD request and returns a
Crest::Response. -
.options(url : String, form = {} of String => String, **args, &block : Crest::Response -> ) : Nil
Execute a OPTIONS request and and yields the
Crest::Responseto the block. -
.options(url : String, form = {} of String => String, **args) : Crest::Response
Execute a OPTIONS request and returns a
Crest::Response. -
.patch(url : String, form = {} of String => String, **args, &block : Crest::Response -> ) : Nil
Execute a PATCH request and and yields the
Crest::Responseto the block. -
.patch(url : String, form = {} of String => String, **args) : Crest::Response
Execute a PATCH request and returns a
Crest::Response. -
.post(url : String, form = {} of String => String, **args, &block : Crest::Response -> ) : Nil
Execute a POST request and and yields the
Crest::Responseto the block. -
.post(url : String, form = {} of String => String, **args) : Crest::Response
Execute a POST request and returns a
Crest::Response. -
.put(url : String, form = {} of String => String, **args, &block : Crest::Response -> ) : Nil
Execute a PUT request and and yields the
Crest::Responseto the block. -
.put(url : String, form = {} of String => String, **args) : Crest::Response
Execute a PUT request and returns a
Crest::Response.
Class Method Detail
Execute a DELETE request and and yields the Crest::Response to the block.
Crest.delete("http://httpbin.org/delete") do |response|
while line = response.body_io.gets
puts line
end
end
Execute a DELETE request and returns a Crest::Response.
Crest.delete("http://httpbin.org/delete")
Execute a GET request and and yields the Crest::Response to the block.
Crest.get("http://httpbin.org/get") do |response|
while line = response.body_io.gets
puts line
end
end
Execute a GET request and returns a Crest::Response.
Crest.get("http://httpbin.org/get")
Execute a HEAD request and and yields the Crest::Response to the block.
Crest.head("http://httpbin.org/head") do |response|
while line = response.body_io.gets
puts line
end
end
Execute a HEAD request and returns a Crest::Response.
Crest.head("http://httpbin.org/head")
Execute a OPTIONS request and and yields the Crest::Response to the block.
Crest.options("http://httpbin.org/options") do |response|
while line = response.body_io.gets
puts line
end
end
Execute a OPTIONS request and returns a Crest::Response.
Crest.options("http://httpbin.org/options")
Execute a PATCH request and and yields the Crest::Response to the block.
Crest.patch("http://httpbin.org/patch") do |response|
while line = response.body_io.gets
puts line
end
end
Execute a PATCH request and returns a Crest::Response.
Crest.patch("http://httpbin.org/patch")
Execute a POST request and and yields the Crest::Response to the block.
Crest.post("http://httpbin.org/post") do |response|
while line = response.body_io.gets
puts line
end
end
Execute a POST request and returns a Crest::Response.
Crest.post("http://httpbin.org/post")
Execute a PUT request and and yields the Crest::Response to the block.
Crest.put("http://httpbin.org/put") do |response|
while line = response.body_io.gets
puts line
end
end
Execute a PUT request and returns a Crest::Response.
Crest.put("http://httpbin.org/put")