引入依赖
<dependency>
<groupId>io.esastack</groupId>
<artifactId>restlight-jaxrs-provider</artifactId>
<version>${restlight.version}</version>
</dependency>
This is the multi-page printable view of this section. Click here to print.
Restlight支持了JAX-RS的使用习惯,你可以按照JAX-RS的方式使用Restlight引入依赖
<dependency>
<groupId>io.esastack</groupId>
<artifactId>restlight-jaxrs-provider</artifactId>
<version>${restlight.version}</version>
</dependency>
@Path@GET@POST@PUT@DELETE@HEAD@PATCH@OPTIONS@Consumes@Produces@QueryParam@PathParam@HeaderParam@MatrixParam@CookieParam@FormParam@BeanParam@DefaultValueRestlight仅实现了JAX-RS的注解, 其余功能暂未实现(Provider, Request, Response)等暂不支持
@QueryParam, @PathParam,@HeaderParam,@MatrixParam, @MatrixVariable,@FormParam
参数绑不支持javax.ws.rs.ext.ParamConverterProvier扩展
@QueryParam除普通用法外, 当未指定value()或者name且参数对象为Map<String, List<String>类型时, 将整个ParameterMap(即AsyncRequest.getParameterMap)作为参数的值。
eg.
public void foo(@QueryParam Map<String, List<String> params) {
//...
}
@CookieParam普通String类型
public void foo(@CookieParam String c) {
//...
}
Cookie对象(io.netty.handler.codec.http.cookie.Cookie)
public void foo(@CookieParam Cookie c) {
//...
}
获取所有的Cookie
public void foo(@CookieParam Set<Cookie> cookies) {
//...
}
JAX-RS中的jax.ws.rs.core.Cookie, 仅支持io.netty.handler.codec.http.cookie.Cookie
@HeaderParam除获取单个header之外, 可以如果参数类型为io.netty.handler.codec.http.HttpHeaders则以所有的Header作为参数的值
eg:
public void foo(@HeaderParam HttpHeaders headers) {
//...
}