class

Halite::Client

Inherits Halite::Chainable / Reference / Object

Clients make requests and receive responses

Support all Chainable methods.

Simple setup

client = Halite::Client.new(headers: {
  "private-token" => "bdf39d82661358f80b31b67e6f89fee4"
})

client.auth(private_token: "bdf39d82661358f80b31b67e6f89fee4").
      .get("http://httpbin.org/get", params: {
        name: "icyleaf"
      })

Setup with block

client = Halite::Client.new do
  basic_auth "name", "foo"
  headers content_type: "application/jsong"
  read_timeout 3.minutes
  logging true
end

Constructors

new(options : Halite::Options = Halite::Options.new)

Instance a new client

options = Halite::Options.new(headers: {
  "private-token" => "bdf39d82661358f80b31b67e6f89fee4",
})

client = Halite::Client.new(options)
Source
new(*, endpoint : String | URI | Nil = nil, headers : Hash(String, _) | NamedTuple | Nil = nil, cookies : Hash(String, _) | NamedTuple | Nil = nil, params : Hash(String, _) | NamedTuple | Nil = nil, form : Hash(String, _) | NamedTuple | Nil = nil, json : Hash(String, _) | NamedTuple | Nil = nil, raw : String | Nil = nil, timeout = Timeout.new, follow = Follow.new, tls : OpenSSL::SSL::Context::Client | Nil = nil)

Instance a new client

Halite::Client.new(headers: {"private-token" => "bdf39d82661358f80b31b67e6f89fee4"})
Source
new

Instance a new client with block

client = Halite::Client.new do
  basic_auth "name", "foo"
  logging true
end
Source

Instance methods

options
Source
options=(options : Halite::Options)
Source
request(verb : String, uri : String, options : Halite::Options | Nil = nil) : Halite::Response

Make an HTTP request

Source
request(verb : String, uri : String, options : Halite::Options | Nil = nil, &block : Halite::Response -> )

Make an HTTP request

Source