将 Clojure 与基于注释的 REST 服务器结合使用
我正在考虑使用 Clojure 编写 REST 服务器。
我有在 Java 中使用 RESTEasy 的经验。它使用注释将 URL、模板参数和查询参数与 Java 类、方法和方法参数相关联。我相信 Jersey REST 服务器也使用注释(因为它也基于 JAX-RS)。
是否可以将这些框架与 Clojure 一起使用?有没有官方的方法将注释与函数关联起来?
I am considering writing a REST Server using Clojure.
I have experience using RESTEasy with Java. It uses annotations to associate URLs, template parameters, and query parameters with Java classes, methods, and method parameters. I believe that the Jersey REST Server also uses annotations (since it, too, is based on JAX-RS).
Is it possible to use these frameworks with Clojure? Is there an official way to associate annotations with functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 Chas Emerick、Brian Carper 和 Christophe Grand 即将出版的《Clojure 编程》一书中找到了答案。
如果您使用
deftype
定义新类型,则可以为新创建的类添加注释:我不确定这是否适用于
gen-class
。我需要进行实验。I found the answer in the forth-coming book "Clojure Programming", by Chas Emerick, Brian Carper, and Christophe Grand.
If you define a new type with
deftype
, you can add annotations the newly created class:I'm not sure if this will work with
gen-class
. I'll need to experiment.