-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(mercury): New module agent-cli-didcommx (#125)
New module agent-cli-didcommx Cleanup dependencies from agent-didcommx
- Loading branch information
1 parent
3804e31
commit 7f2434d
Showing
12 changed files
with
92 additions
and
59 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
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
8 changes: 3 additions & 5 deletions
8
.../scala/io/iohk/atala/AgentClientBob.scala → .../scala/io/iohk/atala/AgentClientBob.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
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
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
...ury-library/agent-cli-didcommx/src/main/scala/io/iohk/atala/mercury/HttpClientZhttp.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 io.iohk.atala.mercury | ||
|
||
import zio._ | ||
import zhttp.service._ | ||
import zhttp.http._ | ||
import io.iohk.atala.mercury._ | ||
|
||
object HttpClientZhttp { | ||
val layer = ZLayer.succeed(new HttpClientZhttp()) | ||
} | ||
|
||
class HttpClientZhttp extends HttpClient { | ||
|
||
val env = ChannelFactory.auto ++ EventLoopGroup.auto() | ||
|
||
override def get(url: String): Task[HttpResponseBody] = | ||
Client | ||
.request(url) | ||
.provideSomeLayer(env) | ||
.flatMap(_.body.asString) | ||
.map(e => HttpResponseBody(e)) | ||
|
||
def postDIDComm(url: String, data: String): Task[HttpResponseBody] = | ||
Client | ||
.request( | ||
url = url, // TODO make ERROR type | ||
method = Method.POST, | ||
headers = Headers("content-type" -> "application/didcomm-encrypted+json"), | ||
// headers = Headers("content-type" -> MediaTypes.contentTypeEncrypted), | ||
content = Body.fromChunk(Chunk.fromArray(data.getBytes)), | ||
// ssl = ClientSSLOptions.DefaultSSL, | ||
) | ||
.provideSomeLayer(env) | ||
.flatMap(_.body.asString) | ||
.map(e => HttpResponseBody(e)) | ||
} |
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
10 changes: 10 additions & 0 deletions
10
mercury/mercury-library/agent/src/main/scala/io/iohk/atala/mercury/HttpClient.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,10 @@ | ||
package io.iohk.atala.mercury | ||
|
||
import zio._ | ||
|
||
case class HttpResponseBody(bodyAsString: String) | ||
|
||
trait HttpClient { | ||
def get(url: String): Task[HttpResponseBody] | ||
def postDIDComm(url: String, data: String): Task[HttpResponseBody] | ||
} |
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