=htp #17082 fix response message generated for MethodRejection
This commit is contained in:
parent
37aa2cb886
commit
0925a23be5
2 changed files with 6 additions and 3 deletions
|
|
@ -167,7 +167,10 @@ class BasicRouteSpecs extends RoutingSpec {
|
|||
Get("/abc") ~> Route.seal {
|
||||
post { completeOk } ~
|
||||
authorize(false) { completeOk }
|
||||
} ~> check { status shouldEqual StatusCodes.MethodNotAllowed }
|
||||
} ~> check {
|
||||
status shouldEqual StatusCodes.MethodNotAllowed
|
||||
responseAs[String] shouldEqual "HTTP method not allowed, supported methods: POST"
|
||||
}
|
||||
|
||||
Get("/abc") ~> Route.seal {
|
||||
authorize(false) { completeOk } ~
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ object RejectionHandler {
|
|||
complete(BadRequest, "Uri scheme not allowed, supported schemes: " + schemes)
|
||||
}
|
||||
.handleAll[MethodRejection] { rejections ⇒
|
||||
val methods = rejections.map(_.supported)
|
||||
complete(MethodNotAllowed, List(Allow(methods)), "HTTP method not allowed, supported methods: " + methods.mkString(", "))
|
||||
val (methods, names) = rejections.map(r ⇒ r.supported -> r.supported.name).unzip
|
||||
complete(MethodNotAllowed, List(Allow(methods)), "HTTP method not allowed, supported methods: " + names.mkString(", "))
|
||||
}
|
||||
.handle {
|
||||
case AuthorizationFailedRejection ⇒
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue