From 41bbe08c125bb3714aee862ec9dc55419c29986d Mon Sep 17 00:00:00 2001 From: adamw Date: Mon, 4 Sep 2017 12:11:34 +0200 Subject: Add an option to attach arbitrary tags to requests for logging/metrics/... integrations --- core/src/main/scala/com/softwaremill/sttp/RequestT.scala | 5 ++++- core/src/main/scala/com/softwaremill/sttp/package.scala | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/core/src/main/scala/com/softwaremill/sttp/RequestT.scala b/core/src/main/scala/com/softwaremill/sttp/RequestT.scala index 95dc56b..27ed7f3 100644 --- a/core/src/main/scala/com/softwaremill/sttp/RequestT.scala +++ b/core/src/main/scala/com/softwaremill/sttp/RequestT.scala @@ -16,6 +16,8 @@ import scala.language.higherKinds * client code to consume it. An exception to this are * streaming responses, which need to fully consumed by the * client if such a response type is requested. + * @param tags Request-specific tags which can be used by handlers for + * logging, metrics, etc. Not used by default. * @tparam U Specifies if the method & uri are specified. By default can be * either: * * `Empty`, which is a type constructor which always resolves to @@ -32,7 +34,8 @@ case class RequestT[U[_], T, +S]( body: RequestBody[S], headers: Seq[(String, String)], response: ResponseAs[T, S], - options: RequestOptions + options: RequestOptions, + tags: Map[String, Any] ) { def get(uri: Uri): Request[T, S] = this.copy[Id, T, S](uri = uri, method = Method.GET) diff --git a/core/src/main/scala/com/softwaremill/sttp/package.scala b/core/src/main/scala/com/softwaremill/sttp/package.scala index 63b82f0..dc51ab2 100644 --- a/core/src/main/scala/com/softwaremill/sttp/package.scala +++ b/core/src/main/scala/com/softwaremill/sttp/package.scala @@ -60,7 +60,8 @@ package object sttp { NoBody, Vector(), asString, - RequestOptions(followRedirects = true)) + RequestOptions(followRedirects = true), + Map()) /** * A starting request, with the following modifications comparing to -- cgit v1.2.3