aboutsummaryrefslogtreecommitdiff
path: root/kamon-core/src/main/scala/kamon/instrumentation/HttpMessage.scala
blob: b141331b3e80810166d3976c3ac156ce05482a63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package kamon.instrumentation

import kamon.context.HttpPropagation.{HeaderReader, HeaderWriter}

/**
  * Base abstractions over HTTP messages.
  */
object HttpMessage {

  /**
    * Wrapper for HTTP Request messages.
    */
  trait Request extends HeaderReader {

    /**
      * Request URL.
      */
    def url: String

    /**
      * Full request path. Does not include the query.
      */
    def path: String

    /**
      * HTTP Method.
      */
    def method: String
  }

  /**
    * Wrapper for HTTP response messages.
    */
  trait Response {

    /**
      * Status code on the response message.
      */
    def statusCode: Int
  }

  /**
    * A HTTP message builder on which header values can be written and a complete HTTP message can be build from.
    * Implementations will typically wrap a HTTP message model from an instrumented framework and either accumulate
    * all header writes until a call to to .build() is made and a new HTTP message is constructed merging the previous
    * and accumulated headers (on immutable HTTP models) or directly write the headers on the underlying HTTP message
    * (on mutable HTTP models).
    */
  trait Builder[Message] extends HeaderWriter {

    /**
      * Returns a version a version of the HTTP message container all headers that have been written to the builder.
      */
    def build(): Message
  }

  /**
    * Builder for HTTP Request messages.
    */
  trait RequestBuilder[Message] extends Request with Builder[Message]

  /**
    * Builder for HTTP Response messages.
    */
  trait ResponseBuilder[Message] extends Response with Builder[Message]
}