+doc,htp #18496 overrideMethodWithParameter

This commit is contained in:
Konrad Malawski 2015-10-08 16:26:29 +02:00
parent 9edffd0930
commit ce07ae75b7
8 changed files with 38 additions and 70 deletions

View file

@ -99,4 +99,28 @@ class MethodDirectivesExamplesSpec extends RoutingSpec {
responseAs[String] shouldEqual "This HEAD request, clearly is not a GET!"
}
}
}
"overrideMethodWithParameter-0" in {
val route =
overrideMethodWithParameter("method") {
get {
complete("This looks like a GET request.")
} ~
post {
complete("This looks like a POST request.")
}
}
Get("/?method=POST") ~> route ~> check {
responseAs[String] shouldEqual "This looks like a POST request."
}
Post("/?method=get") ~> route ~> check {
responseAs[String] shouldEqual "This looks like a GET request."
}
Get("/?method=hallo") ~> route ~> check {
status shouldEqual StatusCodes.NotImplemented
}
}
}

View file

@ -5,10 +5,7 @@
package docs.http.scaladsl.server
package directives
import akka.http.scaladsl.server.UnacceptedResponseContentTypeRejection
import akka.http.scaladsl.model._
import akka.http.scaladsl.model.headers._
import headers._
class RespondWithDirectivesExamplesSpec extends RoutingSpec {
@ -130,18 +127,4 @@ class RespondWithDirectivesExamplesSpec extends RoutingSpec {
// }
// }
// FIXME https://github.com/akka/akka/issues/18626
// "respondWithStatus-examples" in {
// val route =
// path("foo") {
// respondWithStatus(201) {
// complete("beep")
// }
// }
//
// Get("/foo") ~> route ~> check {
// status shouldEqual StatusCodes.Created
// responseAs[String] shouldEqual "beep"
// }
// }
}
}