I am developing a service that is called on one path with different query parameters. I have bind a Route to Http:
val route: Route = {
get {
pathPrefix("myRoute"){
parameterMap{ params =>
complete(
MyHandler.genExternResponse(params)
)
}
}
}
val bindingFuture = Http().bindAndHandleAsync(Route.asyncHandler(new myEndpoint().route), "localhost", 8081)
Since i have no influence on what parameters are used, i can't eliminate the calls that contain not-encoded special chars like German umlauts or trademark signs. for example
www.myhost.com/myRoute?param1=asd¶m2=adäöü
I know that those URLs are not valid But one of the requirements is that even requests with those chars are accepted und that i handle them with URL encoding. The problem is that when i call the service like above, akka-http rejects the request with the Response-status 400 without even handing it to my code. Is there a way that i can catch those request and handle them by myself or let akka-http URL-encode the special chars for me.
edit: will not solve
MyHandler.genExternResponse
which is throwing an exception? Exceptions thrown here will convert to a 400. If you change your code to a complete ("ok") you don't get the error, so it's unlikely to be Akka's fault – Stefano Bonetticomplete("ok")
– Stefano Bonetti