简体   繁体   English

其余-API网址中的“:”和“ {}”有什么区别?

[英]Rest - What is difference between “:” and “{}” in API url?

I have seen two styles ( /api/users/:uid and /api/users/{uid} ) when designing API: 在设计API时,我看到了两种样式( /api/users/:uid/api/users/{uid} ):

Do they have different meanings? 它们有不同的含义吗? Or just styles? 还是只是样式?

Both examples refer to captured elements of a submitted URL. 这两个示例都引用了提交的URL的捕获元素。 When your service receives a request in the form of /api/users/foo , the controller (or whatever piece of code gets invoked to process the request) will receive a request parameter named uid with value foo . 当您的服务收到/api/users/foo形式的请求时,控制器(或调用任何代码来处理该请求的代码)将收到一个名为uid的请求参数,其值为foo Whether it's prefixed with a colon, or wrapped in braces depends on the syntax of the particular framework you're using. 是否以冒号作为前缀,或用大括号括起来取决于您所使用的特定框架的语法。

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

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