gleetube/config
Types
Client configuration. Not opaque — allows record update syntax for easy customization.
pub type Config {
Config(
auth: auth.Auth,
base_url: String,
timeout_ms: Int,
headers: List(#(String, String)),
transport: fn(request.Request(String), Int) -> Result(
response.Response(String),
error.GleeTubeError,
),
transport_bits: fn(request.Request(BitArray), Int) -> Result(
response.Response(BitArray),
error.GleeTubeError,
),
)
}
Constructors
-
Config( auth: auth.Auth, base_url: String, timeout_ms: Int, headers: List(#(String, String)), transport: fn(request.Request(String), Int) -> Result( response.Response(String), error.GleeTubeError, ), transport_bits: fn(request.Request(BitArray), Int) -> Result( response.Response(BitArray), error.GleeTubeError, ), )
HTTP transport function for string-body requests.
pub type Transport =
fn(request.Request(String), Int) -> Result(
response.Response(String),
error.GleeTubeError,
)
HTTP transport function for binary-body requests (used by resumable uploads).
pub type TransportBits =
fn(request.Request(BitArray), Int) -> Result(
response.Response(BitArray),
error.GleeTubeError,
)
Values
pub const default_timeout_ms: Int
Default request timeout in milliseconds (30 seconds).
pub fn new(auth: auth.Auth) -> Config
Create a Config with default settings for the given auth. Uses gleam_httpc as the default HTTP transport.
pub fn with_base_url(config: Config, base_url: String) -> Config
Set a custom base URL (useful for testing with a mock server).
pub fn with_headers(
config: Config,
headers: List(#(String, String)),
) -> Config
Set custom HTTP headers to include with every request.
pub fn with_timeout(config: Config, timeout_ms: Int) -> Config
Set a custom timeout in milliseconds.
pub fn with_transport(
config: Config,
transport: fn(request.Request(String), Int) -> Result(
response.Response(String),
error.GleeTubeError,
),
transport_bits: fn(request.Request(BitArray), Int) -> Result(
response.Response(BitArray),
error.GleeTubeError,
),
) -> Config
Set a custom HTTP transport (e.g., hackney adapter for proxy support).
Example
import gleetube/adapter/hackney_adapter
let opts = hackney_adapter.new() |> hackney_adapter.with_proxy("http://proxy:8080")
let config =
config.new(auth)
|> config.with_transport(
hackney_adapter.transport(opts),
hackney_adapter.transport_bits(opts),
)