我有一个与REST网址设计相关的问题.我在这里找到了一些相关的帖子:同一资源的不同RESTful表示,这里:RESTful url来获取不同字段的GET资源,但响应并不十分清楚最佳实践是什么以及为什么.这是一个例子.
我有用于表示"用户"资源的REST URL.我可以使用id或电子邮件地址获取用户,但两者的URL表示形式保持不变.通过大量的博客和书籍,我看到人们已经以不同的方式做到了这一点.例如
在书中和stackoverflow上的某个地方阅读这个练习(我似乎无法再找到链接)
GET /users/id={id}
GET /users/email={email}
Run Code Online (Sandbox Code Playgroud)
在很多博客上阅读这种做法
GET /users/{id}
GET /users/email/{email}
Run Code Online (Sandbox Code Playgroud)
查询参数通常用于过滤网址所代表的资源的结果,但我也看到了这种做法
GET /users?id={id}
GET /users?email={email}
Run Code Online (Sandbox Code Playgroud)
我的问题是,在所有这些实践中,对于使用api的开发人员来说哪一个最有意义?为什么?我相信在REST网址设计和命名约定方面没有任何规则,但我只是想知道应采取哪条路线来帮助开发人员更好地理解apis.
所有帮助赞赏!
我们刚刚将dropwizard版本从0.6.2或0.7升级,发现很多配置在.yml文件中已经改变.虽然我们能够找出大部分内容,但我们无法弄清楚如何关闭"requestLog".在0.6.2中,我们做了以下事情:
requestLog:
# Settings for logging to stdout.
console:
# If true, log requests to stdout.
enabled: false
# The time zone in which dates should be displayed.
Run Code Online (Sandbox Code Playgroud)
但是看看新文档:
我们没有看到任何关于如何禁用请求日志的参考.关于如何实现我们关闭dropwizard 0.7中的请求日志的目标的任何想法?
我编写了自己的扫描程序来浏览我的JAX-RS资源并使用打印出方法名称和路径jersey-server-1.18.1.问题是当我将相同的代码迁移到2.16(将包名更改com.sun.*为org.glassfish.*)时,它将无法正常工作.
深入挖掘我发现那些必需的jersey-server课程并不公开.谁知道原因?如何将我的代码从1.x迁移到2.x?实际上没有关于此迁移的文档.
所有帮助赞赏!下面是1.x的代码
import com.wordnik.swagger.annotations.ApiOperation;
import com.sun.jersey.api.model.AbstractResource;
import com.sun.jersey.api.model.AbstractResourceMethod;
import com.sun.jersey.api.model.AbstractSubResourceLocator;
import com.sun.jersey.api.model.AbstractSubResourceMethod;
import com.sun.jersey.server.impl.modelapi.annotation.IntrospectionModeller;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author shivang
*/
public class Apiscanner {
public static void main(String[] args) {
Apiscanner runClass = new Apiscanner();
runClass.xyz();
}
public void …Run Code Online (Sandbox Code Playgroud) rest ×3
jax-rs ×2
dropwizard ×1
java ×1
jersey-1.0 ×1
jersey-2.0 ×1
url ×1
url-pattern ×1
url-scheme ×1
yaml ×1