Skip to content

Commit

Permalink
feat: adding query url form encoding to smithy client endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MoeQuadrat committed Aug 21, 2024
1 parent a32c580 commit c6e7de1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ package client
import cats.implicits._
import smithy4s.codecs.PayloadError
import smithy4s.http._
import smithy4s.{ Blob, Endpoint, Hints, Schema }
import smithy4s.{Blob, Endpoint, Hints, Schema}

import scala.concurrent.{ ExecutionContext, Future }
import java.net.URLEncoder
import java.nio.charset.StandardCharsets
import scala.concurrent.{ExecutionContext, Future}

private[smithy4play] class SmithyPlayClientEndpoint[Op[_, _, _, _, _], I, E, O, SI, SO](
endpoint: Endpoint[Op, I, E, O, SI, SO],
Expand Down Expand Up @@ -97,7 +99,7 @@ private[smithy4play] class SmithyPlayClientEndpoint[Op[_, _, _, _, _], I, E, O,

def buildPath(metadata: Metadata): String =
baseUri + httpEndpoint.path(input).mkString("/") + metadata.queryFlattened
.map(s => s._1 + "=" + s._2)
.map(s => URLEncoder.encode(s._1, StandardCharsets.UTF_8.name()) + "=" + URLEncoder.encode(s._2, StandardCharsets.UTF_8.name()))
.mkString("?", "&", "")

}
2 changes: 1 addition & 1 deletion smithy4playTest/test/TestControllerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class TestControllerTest extends TestBase {

"route to Test Endpoint by SmithyTestClient with Query Parameter, Path Parameter and Body" in {
val pathParam = "thisIsAPathParam"
val testQuery = "thisIsATestQuery"
val testQuery = "this Is A Test Query"
val testHeader = "thisIsATestHeader"
val body = TestRequestBody("thisIsARequestBody")
val result = genericClient.testWithOutput(pathParam, testQuery, testHeader, body).awaitRight
Expand Down

0 comments on commit c6e7de1

Please sign in to comment.