Skip to content

Commit

Permalink
Merge pull request #312 from innFactory/feat/query-url-encoding
Browse files Browse the repository at this point in the history
feat: adding query url form encoding to smithy client endpoint
  • Loading branch information
MoeQuadrat authored Aug 21, 2024
2 parents a32c580 + 51f52fd commit 2b76f32
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import smithy4s.codecs.PayloadError
import smithy4s.http._
import smithy4s.{ Blob, Endpoint, Hints, Schema }

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

private[smithy4play] class SmithyPlayClientEndpoint[Op[_, _, _, _, _], I, E, O, SI, SO](
Expand Down Expand Up @@ -97,7 +99,10 @@ 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 2b76f32

Please sign in to comment.