-
Notifications
You must be signed in to change notification settings - Fork 315
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1716 from haoqin/1654
1654
- Loading branch information
Showing
11 changed files
with
174 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
armeria-backend/zio/src/main/scala/sttp/client3/armeria/zio/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package sttp.client3.armeria | ||
|
||
import _root_.zio._ | ||
import sttp.capabilities.Effect | ||
import sttp.capabilities.zio.ZioStreams | ||
import sttp.client3._ | ||
import sttp.client3.impl.zio.ExtendEnv | ||
|
||
package object zio { | ||
|
||
/** Type alias to be used as the sttp ZIO service (mainly in ZIO environment). */ | ||
type SttpClient = SttpBackend[Task, ZioStreams] | ||
|
||
/** Sends the request. Only requests for which the method & URI are specified can be sent. | ||
* | ||
* @return | ||
* An effect resulting in a`Response`, containing the body, deserialized as specified by the request (see | ||
* `RequestT.response`), if the request was successful (1xx, 2xx, 3xx response codes), or if there was a | ||
* protocol-level failure (4xx, 5xx response codes). | ||
* | ||
* A failed effect, if an exception occurred when connecting to the target host, writing the request or reading the | ||
* response. | ||
* | ||
* Known exceptions are converted to one of `SttpClientException`. Other exceptions are kept unchanged. | ||
*/ | ||
def send[T](request: Request[T, Effect[Task] with ZioStreams]): ZIO[SttpClient, Throwable, Response[T]] = | ||
ZIO.serviceWithZIO[SttpClient](_.send(request)) | ||
|
||
/** A variant of `send` which allows the effects that are part of the response handling specification (when using | ||
* websockets or resource-safe streaming) to use an `R` environment. | ||
*/ | ||
def sendR[T, R]( | ||
request: Request[T, Effect[RIO[R, *]] with ZioStreams] | ||
): ZIO[SttpClient with R, Throwable, Response[T]] = | ||
ZIO.serviceWithZIO[SttpClient](_.extendEnv[R].send(request)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
async-http-client-backend/zio/src/main/scala/sttp/client3/asynchttpclient/zio/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package sttp.client3.asynchttpclient | ||
|
||
import _root_.zio._ | ||
import sttp.capabilities.Effect | ||
import sttp.capabilities.zio.ZioStreams | ||
import sttp.client3._ | ||
import sttp.client3.impl.zio.ExtendEnv | ||
|
||
package object zio { | ||
|
||
/** Type alias to be used as the sttp ZIO service (mainly in ZIO environment). */ | ||
type SttpClient = SttpBackend[Task, ZioStreams] | ||
|
||
/** Sends the request. Only requests for which the method & URI are specified can be sent. | ||
* | ||
* @return | ||
* An effect resulting in a`Response`, containing the body, deserialized as specified by the request (see | ||
* `RequestT.response`), if the request was successful (1xx, 2xx, 3xx response codes), or if there was a | ||
* protocol-level failure (4xx, 5xx response codes). | ||
* | ||
* A failed effect, if an exception occurred when connecting to the target host, writing the request or reading the | ||
* response. | ||
* | ||
* Known exceptions are converted to one of `SttpClientException`. Other exceptions are kept unchanged. | ||
*/ | ||
def send[T](request: Request[T, Effect[Task] with ZioStreams]): ZIO[SttpClient, Throwable, Response[T]] = | ||
ZIO.serviceWithZIO[SttpClient](_.send(request)) | ||
|
||
/** A variant of `send` which allows the effects that are part of the response handling specification (when using | ||
* websockets or resource-safe streaming) to use an `R` environment. | ||
*/ | ||
def sendR[T, R]( | ||
request: Request[T, Effect[RIO[R, *]] with ZioStreams] | ||
): ZIO[SttpClient with R, Throwable, Response[T]] = | ||
ZIO.serviceWithZIO[SttpClient](_.extendEnv[R].send(request)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
effects/zio/src/main/scalajvm/sttp/client3/httpclient/zio/package.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package sttp.client3.httpclient | ||
|
||
import _root_.zio._ | ||
import sttp.capabilities.{Effect, WebSockets} | ||
import sttp.capabilities.zio.ZioStreams | ||
import sttp.client3._ | ||
import sttp.client3.impl.zio.ExtendEnv | ||
|
||
package object zio { | ||
/** Type alias to be used as the sttp ZIO service (mainly in ZIO environment). */ | ||
type SttpClient = SttpBackend[Task, ZioStreams with WebSockets] | ||
|
||
/** Sends the request. Only requests for which the method & URI are specified can be sent. | ||
* | ||
* @return | ||
* An effect resulting in a`Response`, containing the body, deserialized as specified by the request (see | ||
* `RequestT.response`), if the request was successful (1xx, 2xx, 3xx response codes), or if there was a | ||
* protocol-level failure (4xx, 5xx response codes). | ||
* | ||
* A failed effect, if an exception occurred when connecting to the target host, writing the request or reading the | ||
* response. | ||
* | ||
* Known exceptions are converted to one of `SttpClientException`. Other exceptions are kept unchanged. | ||
*/ | ||
def send[T]( | ||
request: Request[T, Effect[Task] with ZioStreams with WebSockets] | ||
): ZIO[SttpClient, Throwable, Response[T]] = | ||
ZIO.serviceWithZIO[SttpClient](_.send(request)) | ||
|
||
/** A variant of `send` which allows the effects that are part of the response handling specification (when using | ||
* websockets or resource-safe streaming) to use an `R` environment. | ||
*/ | ||
def sendR[T, R]( | ||
request: Request[T, Effect[RIO[R, *]] with ZioStreams with WebSockets] | ||
): ZIO[SttpClient with R, Throwable, Response[T]] = | ||
ZIO.serviceWithZIO[SttpClient](_.extendEnv[R].send(request)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters