All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ratpack.kotlin.client.KHttpClient.kt Maven / Gradle / Ivy

There is a newer version: 1.10.3
Show newest version
package ratpack.kotlin.client

import ratpack.exec.Promise
import ratpack.func.Action
import ratpack.http.client.HttpClient
import ratpack.http.client.ReceivedResponse
import ratpack.http.client.RequestSpec
import java.net.URI

fun HttpClient.get(uri: String, action: (RequestSpec) -> Unit): Promise {
  return get(URI.create(uri), action)
}

fun HttpClient.get(uri: String): Promise {
  val action: (RequestSpec) -> Unit = {}
  return get(uri, action)
}

fun HttpClient.put(uri: URI, action: Action): Promise {
  return request(uri, action.prepend { it.put() })
}

fun HttpClient.put(uri: URI): Promise {
  return put(uri, Action.noop())
}

fun HttpClient.put(uri: String, action: (RequestSpec) -> Unit): Promise {
  return put(URI.create(uri), Action { action(it) })
}

fun HttpClient.put(uri: String): Promise {
  val action: (RequestSpec) -> Unit = {}
  return put(uri, action)
}

fun HttpClient.post(uri: String, action: (RequestSpec) -> Unit): Promise {
  return post(URI.create(uri), action)
}

fun HttpClient.post(uri: String): Promise {
  val action: (RequestSpec) -> Unit = {}
  return post(uri, action)
}

fun HttpClient.delete(uri: URI, action: Action): Promise {
  return request(uri, action.prepend { it.delete() })
}

fun HttpClient.delete(uri: URI): Promise {
  return delete(uri, Action.noop())
}

fun HttpClient.delete(uri: String, action: (RequestSpec) -> Unit): Promise {
  return delete(URI.create(uri), Action { action(it) })
}

fun HttpClient.delete(uri: String): Promise {
  val action: (RequestSpec) -> Unit = {}
  return delete(uri, action)
}

fun HttpClient.patch(uri: URI, action: Action): Promise {
  return request(uri, action.prepend { it.patch() })
}

fun HttpClient.patch(uri: URI): Promise {
  return patch(uri, Action.noop())
}

fun HttpClient.patch(uri: String, action: (RequestSpec) -> Unit): Promise {
  return patch(URI.create(uri), Action { action(it) })
}

fun HttpClient.patch(uri: String): Promise {
  val action: (RequestSpec) -> Unit = {}
  return patch(uri, action)
}

fun HttpClient.options(uri: URI, action: Action): Promise {
  return request(uri, action.prepend { it.options() })
}

fun HttpClient.options(uri: URI): Promise {
  return options(uri, Action.noop())
}

fun HttpClient.options(uri: String, action: (RequestSpec) -> Unit): Promise {
  return options(URI.create(uri), Action { action(it) })
}

fun HttpClient.options(uri: String): Promise {
  val action: (RequestSpec) -> Unit = {}
  return options(uri, action)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy