diff --git a/cask/src/cask/endpoints/FormEndpoint.scala b/cask/src/cask/endpoints/FormEndpoint.scala index 0dd7c1e48b..956e09130b 100644 --- a/cask/src/cask/endpoints/FormEndpoint.scala +++ b/cask/src/cask/endpoints/FormEndpoint.scala @@ -13,6 +13,9 @@ object FormReader{ implicit def paramFormReader[T: QueryParamReader]: FormReader[T] = new FormReader[T]{ def arity = implicitly[QueryParamReader[T]].arity + override def unknownQueryParams: Boolean = implicitly[QueryParamReader[T]].unknownQueryParams + + override def remainingPathSegments: Boolean = implicitly[QueryParamReader[T]].remainingPathSegments def read(ctx: Request, label: String, input: Seq[FormEntry]) = { implicitly[QueryParamReader[T]].read(ctx, label, if (input == null) null else input.map(_.valueOrFileName)) } diff --git a/example/formJsonPost/app/src/FormJsonPost.scala b/example/formJsonPost/app/src/FormJsonPost.scala index 70d7a2644c..e43968c927 100644 --- a/example/formJsonPost/app/src/FormJsonPost.scala +++ b/example/formJsonPost/app/src/FormJsonPost.scala @@ -40,5 +40,13 @@ object FormJsonPost extends cask.MainRoutes{ "OK " + value1 + " " + value2 + " " + params.value + " " + segments.value } + @cask.postForm("/form-extra") + def formEndpointExtra(value1: cask.FormValue, + value2: Seq[Int], + params: cask.QueryParams, + segments: cask.RemainingPathSegments) = { + "OK " + value1 + " " + value2 + " " + params.value + " " + segments.value + } + initialize() } diff --git a/example/formJsonPost/app/test/src/ExampleTests.scala b/example/formJsonPost/app/test/src/ExampleTests.scala index 4d1a1cfbe0..adb2ee1b76 100644 --- a/example/formJsonPost/app/test/src/ExampleTests.scala +++ b/example/formJsonPost/app/test/src/ExampleTests.scala @@ -58,6 +58,23 @@ object ExampleTests extends TestSuite{ s"$host/json-extra/omg/wtf/bbq?iam=cow&hearme=moo", data = """{"value1": true, "value2": [3]}""" ) + + val text6 = response6.text() + assert( + text6 == "\"OK true List(3) Map(hearme -> ArraySeq(moo), iam -> ArraySeq(cow)) List(omg, wtf, bbq)\"" || + text6 == "\"OK true Vector(3) Map(hearme -> WrappedArray(moo), iam -> WrappedArray(cow)) List(omg, wtf, bbq)\"" + ) + + val response7 = requests.post( + s"$host/form-extra/omg/wtf/bbq?iam=cow&hearme=moo", + data = Seq("value1" -> "hello", "value2" -> "1", "value2" -> "2") + ) + + val text7 = response7.text() + assert( + text7 == "OK FormValue(hello,null) List(1, 2) Map(hearme -> ArraySeq(moo), iam -> ArraySeq(cow)) List(omg, wtf, bbq)" || + text7 == "OK FormValue(hello,null) List(1, 2) Map(hearme -> WrappedArray(moo), iam -> WrappedArray(cow)) List(omg, wtf, bbq)" + ) } } }