+doc #20466 example snippet for akka http java dsl: BasicDirectives (#20647)

This commit is contained in:
Hawstein 2016-06-03 19:43:42 +08:00 committed by Konrad Malawski
parent 5afb68cd59
commit f98c1946d8
38 changed files with 914 additions and 52 deletions

View file

@ -303,13 +303,11 @@ class BasicDirectivesExamplesSpec extends RoutingSpec {
"mapRouteResult" in {
//#mapRouteResult
// this directive is a joke, don't do that :-)
val makeEverythingOk = mapRouteResult { r =>
r match {
case Complete(response) =>
// "Everything is OK!"
Complete(response.copy(status = 200))
case _ => r
}
val makeEverythingOk = mapRouteResult {
case Complete(response) =>
// "Everything is OK!"
Complete(response.copy(status = 200))
case r => r
}
val route =
@ -591,11 +589,9 @@ class BasicDirectivesExamplesSpec extends RoutingSpec {
//#mapRouteResultWith-0
case object MyCustomRejection extends Rejection
val rejectRejections = // not particularly useful directive
mapRouteResultWith { res =>
res match {
case Rejected(_) => Future(Rejected(List(AuthorizationFailedRejection)))
case _ => Future(res)
}
mapRouteResultWith {
case Rejected(_) => Future(Rejected(List(AuthorizationFailedRejection)))
case res => Future(res)
}
val route =
rejectRejections {
@ -694,7 +690,7 @@ class BasicDirectivesExamplesSpec extends RoutingSpec {
// tests:
Get("/") ~> route ~> check {
responseAs[String] shouldEqual s"RoutingSettings.renderVanityFooter = true"
responseAs[String] shouldEqual "RoutingSettings.renderVanityFooter = true"
}
//#
}
@ -767,7 +763,7 @@ class BasicDirectivesExamplesSpec extends RoutingSpec {
pathPrefix("123") {
ignoring456 {
path("abc") {
complete(s"Content")
complete("Content")
}
}
}