1
- package sttp .tapir .client .sttp
1
+ package sttp .tapir .client .sttp4
2
2
3
- import sttp .client4 .{Request , SttpBackend }
3
+ import sttp .client4 .{Backend , Request }
4
4
import sttp .model .Uri
5
5
import sttp .tapir .{DecodeResult , Endpoint , PublicEndpoint }
6
6
@@ -17,11 +17,12 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
17
17
* parameters: path, query, headers and body. The request is sent using the given backend, and the result of decoding the response (error
18
18
* or success value) is returned.
19
19
*/
20
- def toClient [F [_], I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ], backend : SttpBackend [ F , R ])(implicit
20
+ def toClient [F [_], I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ], backend : Backend [ F ])(implicit
21
21
wsToPipe : WebSocketToPipe [R ]
22
22
): I => F [DecodeResult [Either [E , O ]]] = {
23
- val req = toRequest(e, baseUri)
24
- (i : I ) => backend.responseMonad.map(backend.send(req(i)))(_.body)
23
+ (i : I ) =>
24
+ val req = toRequest(e, baseUri)
25
+ backend.monad.map(req(i).send(backend))(_.body)
25
26
}
26
27
27
28
/** Interprets the public endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -31,11 +32,11 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
31
32
* parameters: path, query, headers and body. The request is sent using the given backend, and the result (error or success value) is
32
33
* returned. If decoding the result fails, a failed effect is returned instead.
33
34
*/
34
- def toClientThrowDecodeFailures [F [_], I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ], backend : SttpBackend [ F , R ])(
35
+ def toClientThrowDecodeFailures [F [_], I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ], backend : Backend [ F ])(
35
36
implicit wsToPipe : WebSocketToPipe [R ]
36
37
): I => F [Either [E , O ]] = {
37
38
val req = toRequestThrowDecodeFailures(e, baseUri)
38
- (i : I ) => backend.responseMonad .map(backend.send( req(i)))(_.body)
39
+ (i : I ) => backend.monad .map(req(i).send(backend ))(_.body)
39
40
}
40
41
41
42
/** Interprets the public endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -45,11 +46,11 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
45
46
* parameters: path, query, headers and body. The request is sent using the given backend, and the result (success value) is returned. If
46
47
* decoding the result fails, or if the response corresponds to an error value, a failed effect is returned instead.
47
48
*/
48
- def toClientThrowErrors [F [_], I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ], backend : SttpBackend [ F , R ])(implicit
49
+ def toClientThrowErrors [F [_], I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ], backend : Backend [ F ])(implicit
49
50
wsToPipe : WebSocketToPipe [R ]
50
51
): I => F [O ] = {
51
52
val req = toRequestThrowErrors(e, baseUri)
52
- (i : I ) => backend.responseMonad .map(backend.send( req(i)))(_.body)
53
+ (i : I ) => backend.monad .map(req(i).send(backend ))(_.body)
53
54
}
54
55
55
56
/** Interprets the public endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -62,8 +63,9 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
62
63
*/
63
64
def toRequest [I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ])(implicit
64
65
wsToPipe : WebSocketToPipe [R ]
65
- ): I => Request [DecodeResult [Either [E , O ]], R ] =
66
+ ): I => Request [DecodeResult [Either [E , O ]]] = {
66
67
new EndpointToSttpClient (sttpClientOptions, wsToPipe).toSttpRequest(e, baseUri).apply(())
68
+ }
67
69
68
70
/** Interprets the public endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
69
71
* `baseUri` is not provided, the request will be a relative one.
@@ -75,7 +77,7 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
75
77
*/
76
78
def toRequestThrowDecodeFailures [I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ])(implicit
77
79
wsToPipe : WebSocketToPipe [R ]
78
- ): I => Request [Either [E , O ], R ] =
80
+ ): I => Request [Either [E , O ]] =
79
81
i => new EndpointToSttpClient (sttpClientOptions, wsToPipe).toSttpRequest(e, baseUri).apply(()).apply(i).mapResponse(throwDecodeFailures)
80
82
81
83
/** Interprets the public endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -91,7 +93,7 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
91
93
*/
92
94
def toRequestThrowErrors [I , E , O , R ](e : PublicEndpoint [I , E , O , R ], baseUri : Option [Uri ])(implicit
93
95
wsToPipe : WebSocketToPipe [R ]
94
- ): I => Request [O , R ] =
96
+ ): I => Request [O ] =
95
97
i =>
96
98
new EndpointToSttpClient (sttpClientOptions, wsToPipe)
97
99
.toSttpRequest(e, baseUri)
@@ -113,11 +115,11 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
113
115
* appropriate request parameters: path, query, headers and body. The request is sent using the given backend, and the result of decoding
114
116
* the response (error or success value) is returned.
115
117
*/
116
- def toSecureClient [F [_], A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ], backend : SttpBackend [ F , R ])(implicit
118
+ def toSecureClient [F [_], A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ], backend : Backend [ F ])(implicit
117
119
wsToPipe : WebSocketToPipe [R ]
118
120
): A => I => F [DecodeResult [Either [E , O ]]] = {
119
121
val req = toSecureRequest(e, baseUri)
120
- (a : A ) => (i : I ) => backend.responseMonad .map(backend.send(req(a)(i)))(_.body)
122
+ (a : A ) => (i : I ) => backend.monad .map(backend.send(req(a)(i)))(_.body)
121
123
}
122
124
123
125
/** Interprets the secure endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -127,11 +129,11 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
127
129
* appropriate request parameters: path, query, headers and body. The request is sent using the given backend, and the result (error or
128
130
* success value) is returned. If decoding the result fails, a failed effect is returned instead.
129
131
*/
130
- def toSecureClientThrowDecodeFailures [F [_], A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ], backend : SttpBackend [ F , R ])(
132
+ def toSecureClientThrowDecodeFailures [F [_], A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ], backend : Backend [ F ])(
131
133
implicit wsToPipe : WebSocketToPipe [R ]
132
134
): A => I => F [Either [E , O ]] = {
133
135
val req = toSecureRequestThrowDecodeFailures(e, baseUri)
134
- (a : A ) => (i : I ) => backend.responseMonad .map(backend.send(req(a)(i)))(_.body)
136
+ (a : A ) => (i : I ) => backend.monad .map(backend.send(req(a)(i)))(_.body)
135
137
}
136
138
137
139
/** Interprets the secure endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -142,11 +144,11 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
142
144
* value) is returned. If decoding the result fails, or if the response corresponds to an error value, a failed effect is returned
143
145
* instead.
144
146
*/
145
- def toSecureClientThrowErrors [F [_], A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ], backend : SttpBackend [ F , R ])(implicit
147
+ def toSecureClientThrowErrors [F [_], A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ], backend : Backend [ F ])(implicit
146
148
wsToPipe : WebSocketToPipe [R ]
147
149
): A => I => F [O ] = {
148
150
val req = toSecureRequestThrowErrors(e, baseUri)
149
- (a : A ) => (i : I ) => backend.responseMonad .map(backend.send(req(a)(i)))(_.body)
151
+ (a : A ) => (i : I ) => backend.monad .map(backend.send(req(a)(i)))(_.body)
150
152
}
151
153
152
154
/** Interprets the secure endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -159,7 +161,7 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
159
161
*/
160
162
def toSecureRequest [A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ])(implicit
161
163
wsToPipe : WebSocketToPipe [R ]
162
- ): A => I => Request [DecodeResult [Either [E , O ]], R ] =
164
+ ): A => I => Request [DecodeResult [Either [E , O ]]] =
163
165
new EndpointToSttpClient (sttpClientOptions, wsToPipe).toSttpRequest(e, baseUri)
164
166
165
167
/** Interprets the secure endpoint as a client call, using the given `baseUri` as the starting point to create the target uri. If
@@ -172,7 +174,7 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
172
174
*/
173
175
def toSecureRequestThrowDecodeFailures [A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ])(implicit
174
176
wsToPipe : WebSocketToPipe [R ]
175
- ): A => I => Request [Either [E , O ], R ] =
177
+ ): A => I => Request [Either [E , O ]] =
176
178
a =>
177
179
i =>
178
180
new EndpointToSttpClient (sttpClientOptions, wsToPipe).toSttpRequest(e, baseUri).apply(a).apply(i).mapResponse(throwDecodeFailures)
@@ -190,7 +192,7 @@ trait SttpClientInterpreter extends SttpClientInterpreterExtensions {
190
192
*/
191
193
def toSecureRequestThrowErrors [A , I , E , O , R ](e : Endpoint [A , I , E , O , R ], baseUri : Option [Uri ])(implicit
192
194
wsToPipe : WebSocketToPipe [R ]
193
- ): A => I => Request [O , R ] =
195
+ ): A => I => Request [O ] =
194
196
a =>
195
197
i =>
196
198
new EndpointToSttpClient (sttpClientOptions, wsToPipe)
0 commit comments