Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding query url form encoding to smithy client endpoint #312

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading