HttpRequest

interface HttpRequest

Interface for building HTTP requests.

This interface provides methods to configure all aspects of an HTTP request including URL, headers, query parameters, cookies, and request body. It supports various HTTP methods (GET, POST, PUT, DELETE) and body formats (JSON, form data).

The interface is designed to be implemented by different HTTP client libraries while maintaining a consistent API across the SDK.

Inheritors

Properties

Link copied to clipboard
abstract var url: String

The URL of the HTTP request.

Functions

Link copied to clipboard
abstract fun cookie(cookie: String)

Adds a single cookie to the request.

Link copied to clipboard
abstract fun cookies(cookies: List<String>)

Adds multiple cookies to the request.

Link copied to clipboard
abstract fun delete(body: JsonObject = buildJsonObject {})

Sets the HTTP method to DELETE and optionally sets a JSON body.

abstract fun delete(contentType: String = CONTENT_TYPE, body: String)

Sets the HTTP method to DELETE with custom content type and body.

Link copied to clipboard
abstract fun form(formBuilder: MutableMap<String, String>.() -> Unit)

Sets the request body as form data with POST method.

Link copied to clipboard
abstract fun header(name: String): String?

Get the HTTP headers being used for the request.

abstract fun header(name: String, value: String)

Adds a header to the request.

Link copied to clipboard
abstract fun method(): String

Get the HTTP method being used for the request.

Link copied to clipboard
abstract fun parameter(name: String, value: String)

Adds a query parameter to the request URL.

Link copied to clipboard
abstract fun post(body: JsonObject = buildJsonObject {})

Sets the request body as JSON with POST method.

abstract fun post(contentType: String = CONTENT_TYPE, body: String)

Sets the request body with POST method and custom content type.

Link copied to clipboard
abstract fun put(body: JsonObject = buildJsonObject {})

Sets the HTTP method to PUT and optionally sets a JSON body.

abstract fun put(contentType: String = CONTENT_TYPE, body: String)

Sets the HTTP method to PUT with custom content type and body.