-
Notifications
You must be signed in to change notification settings - Fork 1
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 #32 from innFactory/feature/Client
Feature/client
- Loading branch information
Showing
28 changed files
with
724 additions
and
81 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") | ||
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.0.5") | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") | ||
addSbtPlugin("com.codecommit" % "sbt-github-packages" % "0.5.3") | ||
addSbtPlugin("org.wartremover" % "sbt-wartremover" % "3.0.5") | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") | ||
addSbtPlugin("com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % "0.15.2") | ||
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.15") | ||
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.9.3") |
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
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
16 changes: 16 additions & 0 deletions
16
smithy4play/src/main/scala/de/innfactory/smithy4play/client/RequestClient.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,16 @@ | ||
package de.innfactory.smithy4play.client | ||
|
||
import play.api.mvc.Headers | ||
|
||
import scala.concurrent.Future | ||
|
||
case class SmithyClientResponse(body: Option[Array[Byte]], headers: Map[String, Seq[String]], statusCode: Int) | ||
|
||
trait RequestClient { | ||
def send( | ||
method: String, | ||
path: String, | ||
headers: Map[String, Seq[String]], | ||
body: Option[Array[Byte]] | ||
): Future[SmithyClientResponse] | ||
} |
27 changes: 27 additions & 0 deletions
27
smithy4play/src/main/scala/de/innfactory/smithy4play/client/SmithyPlayClient.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,27 @@ | ||
package de.innfactory.smithy4play.client | ||
|
||
import de.innfactory.smithy4play.ClientResponse | ||
import smithy4s.http.HttpEndpoint | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
class SmithyPlayClient[Alg[_[_, _, _, _, _]], Op[_, _, _, _, _], F[_]]( | ||
baseUri: String, | ||
service: smithy4s.Service[Alg, Op] | ||
)(implicit executionContext: ExecutionContext, client: RequestClient) { | ||
|
||
def send[I, E, O, SI, SO]( | ||
op: Op[I, E, O, SI, SO], | ||
additionalHeaders: Option[Map[String, Seq[String]]] | ||
): ClientResponse[O] = { | ||
|
||
val (input, endpoint) = service.endpoint(op) | ||
HttpEndpoint | ||
.cast(endpoint) | ||
.map(httpEndpoint => | ||
new SmithyPlayClientEndpoint(endpoint, baseUri, additionalHeaders, httpEndpoint, input).send() | ||
) | ||
.get | ||
} | ||
|
||
} |
Oops, something went wrong.