简体   繁体   English

基于 header 值的 JAX-RS 调用端点

[英]JAX-RS Invoke endpoint based on header value

Is there a way to use the same path but separated based on the value of the header with out spring framework.有没有办法使用相同的路径,但根据 header 的值在没有 spring 框架的情况下分开。 I'm looking for an equivalent of the below code in JAX-RS我在 JAX-RS 中寻找以下代码的等效项

@RequestMapping(value = "/request", headers={"range=include"}) 
public ResponseEntity<SomeObject> processWithView() {
    return processRequestSomeOther();
}


// request handling (no headers specified) 
@RequestMapping(value = "/request")
public ResponseEntity<SomeObject> processWithoutView() {
    return processRequest();
}

Not exactly like that.不完全一样。 But something like:但是像:

@Path("/request")
public ResponseEntity<SomeObject> processViews(@HeaderParam("range") String range) {
    if( range == null )
        return processRequest();

    return processRequestSomeOther();
}

will do the same thing.会做同样的事情。 Obviously you can parse the headers directly too.显然,您也可以直接解析标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM