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/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 =
{100 => "Continue", 101 => "Switching Protocols", 102 => "Processing", 200 => "OK", 201 => "Created", 202 => "Accepted", 203 => "Non-Authoritative Information", 204 => "No Content", 205 => "Reset Content", 206 => "Partial Content", 207 => "Multi-Status", 208 => "Already Reported", 226 => "IM Used", 300 => "Multiple Choices", 301 => "Moved Permanently", 302 => "Found", 303 => "See Other", 304 => "Not Modified", 305 => "Use Proxy", 306 => "Switch Proxy", 307 => "Temporary Redirect", 308 => "Permanent Redirect", 400 => "Bad Request", 401 => "Unauthorized", 402 => "Payment Required", 403 => "Forbidden", 404 => "Not Found", 405 => "Method Not Allowed", 406 => "Not Acceptable", 407 => "Proxy Authentication Required", 408 => "Request Timeout", 409 => "Conflict", 410 => "Gone", 411 => "Length Required", 412 => "Precondition Failed", 413 => "Payload Too Large", 414 => "URI Too Long", 415 => "Unsupported Media Type", 416 => "Range Not Satisfiable", 417 => "Expectation Failed", 418 => "I\"m A Teapot", 421 => "Too Many Connections From This IP", 422 => "Unprocessable Entity", 423 => "Locked", 424 => "Failed Dependency", 425 => "Unordered Collection", 426 => "Upgrade Required", 428 => "Precondition Required", 429 => "Too Many Requests", 431 => "Request Header Fields Too Large", 449 => "Retry With", 450 => "Blocked By Windows Parental Controls", 500 => "Internal Server Error", 501 => "Not Implemented", 502 => "Bad Gateway", 503 => "Service Unavailable", 504 => "Gateway Timeout", 505 => "HTTP Version Not Supported", 506 => "Variant Also Negotiates", 507 => "Insufficient Storage", 508 => "Loop Detected", 509 => "Bandwidth Limit Exceeded", 510 => "Not Extended", 511 => "Network Authentication Required"}
-
Hash of HTTP status code => message.
-
USER_AGENT =
"Crest/#{Crest::VERSION} (Crystal/#{Crystal::VERSION})"
-
VERSION =
{{ (`shards version /srv/crystaldoc.info/github-mamantoha-crest-v1.4.1/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::Response
to 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::Response
to 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::Response
to 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::Response
to 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::Response
to 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::Response
to 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::Response
to 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")