drip
drip is Kona’s outbound HTTP client. Use it from application code, grind commands, or tests when you need to call another service.
Register
Section titled “Register”app.register(DripServiceProvider())Resolve a shared client from the container, or construct Drip() directly.
Kotlin
Section titled “Kotlin”val drip = Drip().baseUrl("https://api.example.com").withHeaders(mapOf("Accept" to "application/json"))val response = drip.get("/users", mapOf("page" to "1"))if (response.successful()) { val data = response.json()}drip.post("/users", mapOf("name" to "Ada"))drip.put("/users/1", mapOf("name" to "Ada Lovelace"))drip.delete("/users/1")Absolute URLs skip the base URL:
drip.get("https://example.com/health")Drip drip = new Drip().baseUrl("https://api.example.com");DripResponse response = drip.get("/users");boolean ok = response.successful();Response shape
Section titled “Response shape”| Field | Meaning |
|---|---|
status |
HTTP status code |
body |
Response body as text |
headers |
Response headers |
successful() |
True when status is 2xx |
json() |
Parses the body as a JSON object map |
Request timeouts default to a few seconds. JSON bodies set Content-Type: application/json; plain String bodies use text/plain.