这是我的原始路线:
http://localhost:9000/test
我想避免在原始路由中出现任何其他查询字符串参数。例如:
http://localhost:9000/test?a=1
http://localhost:9000/test?b=1
http://localhost:9000/test?c=1
http://localhost:9000/test?d=1&e=2
http://localhost:9000/test?f=1&g=2&h=3
...
所有这些都不在请求中,如果有的话,响应必须是BadRequest(400)。
您可以编写一个控制器来检查请求中是否有参数,如果传递了任何参数,则返回BadRequest,例如:
def endpoint = Action { request =>
if (request.queryString.isEmpty) {
Ok("Valid request")
} else {
BadRequest ("Arguments are not allowed")
}
}