我有以下问题:
我在jooby服务器上有一个rest。我想要创建一个自定义注释拦截器,它处理特定的请求并在报头中验证oauth令牌。
@GET
@Path("current")
@AuthenticationTokenValidator
public Result getCurrentUser(final Request req) {
...或者对整个控制器来说
@Path("/v1/some_route")
@Consumes("json")
@Produces("json")
@AuthenticationTokenValidator
public class SomeController {我怎么能这么做?提前感谢!
发布于 2017-12-06 17:10:39
您需要一个filter,然后请求路由attributes。与此类似的是:
{
use("*", (req, rsp, chain) -> {
String value = req.route().attr("authenticationTokenValidator");
// your code goes here
});
}不确定是否支持类级别的annotation。
查看有关路由属性的文档,有一个类似的例子。
https://stackoverflow.com/questions/47552462
复制相似问题