在 Play 2.5 中使用 akka-http,如何自定义“非法请求目标”

syn*_*tic 5 scala playframework akka-http

我正进入(状态

< HTTP/1.1 400 Bad Request
< Content-Type: text/plain; charset=UTF-8
< Content-Length: 96

Illegal request-target: Invalid input '\', expected pchar, '/', '?' or 'EOI' (line 1, column 17)
Run Code Online (Sandbox Code Playgroud)

对于包含 的 URL \,这没关系,我希望有 400 个,但我想更改消息,因此它对用户更友好。

似乎它发生在它进入任何控制器之前。

ps 我知道有akka.http.parsing.uri-parsing-mode = relaxed,但我不想这样做(我想要的是不同的信息:)。

更新:导致示例 URLIllegal request-target是:

http://host.host/hello\world
http://host.host/hello{all
http://host.host/hello"all
Run Code Online (Sandbox Code Playgroud)

等等