Skip to content

Commit

Permalink
Merge pull request #137 from buildo/api-45-add_https_support
Browse files Browse the repository at this point in the history
#45: Add HTTPS support (closes #45)
  • Loading branch information
danielegallingani authored Sep 19, 2018
2 parents 8f386aa + 6e69017 commit a43e87a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion wiro/clientAkkaHttp/src/main/scala/RPCClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ trait RPCClientContext[T] extends MetaDataMacro with PathMacro {
class RPCClient(
config: Config,
prefix: Option[String] = None,
scheme: String = "http",
ctx: RPCClientContext[_]
)(implicit
system: ActorSystem,
materializer: ActorMaterializer,
executionContext: ExecutionContext
) extends autowire.Client[Json, WiroDecoder, Encoder] {
private[wiro] val requestBuilder = new RequestBuilder(config, prefix, ctx)
private[wiro] val requestBuilder = new RequestBuilder(config, prefix, scheme, ctx)

def write[Result: Encoder](r: Result): Json = r.asJson

Expand Down
7 changes: 4 additions & 3 deletions wiro/clientAkkaHttp/src/main/scala/RequestBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import cats.syntax.either._
class RequestBuilder(
config: Config,
prefix: Option[String],
scheme: String,
ctx: RPCClientContext[_]
) {
def build(path : Seq[String], args: Map[String, Json]): HttpRequest = {
Expand All @@ -29,7 +30,7 @@ class RequestBuilder(
val (headersArgs, remainingArgs) = splitHeaderArgs(nonTokenArgs)
val tokenHeader = handleAuth(tokenArgs.values.toList)
val headers = handleHeaders(headersArgs.values.toList) ++ tokenHeader
val uri = buildUri(operationName, prefix)
val uri = buildUri(operationName)
val httpRequest = methodMetaData.operationType match {
case _: OperationType.Command => commandHttpRequest(remainingArgs, uri)
case _: OperationType.Query => queryHttpRequest(remainingArgs, uri)
Expand All @@ -38,14 +39,14 @@ class RequestBuilder(
httpRequest.withHeaders(headers)
}

private[this] def buildUri(operationName: String, prefix: Option[String]) = {
private[this] def buildUri(operationName: String) = {
val path = prefix match {
case None => Path / ctx.path / operationName
case Some(prefix) => Path / prefix /ctx.path / operationName
}

Uri(
scheme = "http",
scheme = scheme,
path = path,
authority = Authority(host = Host(config.host), port = config.port)
)
Expand Down

0 comments on commit a43e87a

Please sign in to comment.