aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoradamw <adam@warski.org>2017-09-04 12:11:34 +0200
committeradamw <adam@warski.org>2017-09-04 12:11:34 +0200
commit41bbe08c125bb3714aee862ec9dc55419c29986d (patch)
tree45b784dc6679d68c89d674e72d3daa7aea803256
parent97571ff137dbb505e94ccf65ce49af7de68690ad (diff)
downloadsttp-41bbe08c125bb3714aee862ec9dc55419c29986d.tar.gz
sttp-41bbe08c125bb3714aee862ec9dc55419c29986d.tar.bz2
sttp-41bbe08c125bb3714aee862ec9dc55419c29986d.zip
Add an option to attach arbitrary tags to requests for logging/metrics/... integrations
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/RequestT.scala5
-rw-r--r--core/src/main/scala/com/softwaremill/sttp/package.scala3
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