uri - 在 dropwizard 中为 REST web 服务配置 URI 前缀

标签 uri dropwizard

我正在开发 REST API使用下拉向导。 resource可以使用 https://<host>:port/item/1 访问.可以看出,没有 URI字首。如果我必须配置一个 URI前缀什么需要做。可以在yaml中配置吗配置文件?
谢谢!

最佳答案

是的,可以在 YAML 中配置 URI 前缀,也就是根路径。您可以使用简单的服务器工厂配置。很简单,在你的 YAML 中添加这两行。我使用“api”作为前缀。您可以将其替换为所需的 URI 前缀。

server:
  rootPath: '/api/*'

稍微复杂一点的服务器配置看起来像这样,
server:
  adminConnectors:
    -
      port: 18001
      type: http
  adminContextPath: /admin
  applicationConnectors:
    -
      port: 18000
      type: http
  rootPath: /api/*
  type: default

你可以引用这个例子https://github.com/dropwizard/dropwizard/blob/master/dropwizard-example/example.yml服务器和其他配置详细信息。

如果您刚刚开始使用 dropwizard,那么通过此操作也是一个好主意 http://www.dropwizard.io/0.9.2/docs/getting-started.html

关于uri - 在 dropwizard 中为 REST web 服务配置 URI 前缀,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35370353/

相关文章:

android - 如何转换文件 ://uri into content://uri?

c++ - 将 URL 编码转换为可打印字符

java - 如何直接访问 Dropwizard 资源,而不是通过 REST

compiler-errors - Atmosphere 、dropwizard 和 Jersey 注入(inject)错误

azure - redirect_uri 与注册值 Azure AD B2C For LinkedIn 不匹配

javascript - 如何将字符串化对象添加到 url 末尾

android - 从 API 8 开始获取用户/所有者个人资料联系 URI 和用户图像

java - Dropwizard:无法解析配置:logging.appenders

java - Dropwizard - 如何从 View 进行服务器端重定向?

dependency-injection - 使用 Dropwizard 从 Authenticator 访问 HttpServletRequest