gpt4 book ai didi

rest - 内容协商 ("Accept"HTTP header )基于 symfony2.0 中的路由

转载 作者:行者123 更新时间:2023-12-01 02:40:50 25 4
gpt4 key购买 nike

当谈到 REST 服务时,Symfony 开发人员(和说明书)倾向于将资源表示的选择基于 文件扩展名而不是内容协商 ( see this stackoverflow question )。

例子:

article_show:
pattern: /articles/{culture}/{year}/{title}.{_format}
defaults: { _controller: AcmeDemoBundle:Article:show, _format: html }
requirements:
culture: en|fr
_format: html|rss
year: \d+

是否有在服务器端实现正确内容协商的捆绑包/方式?

使用 _format 实现 switch/case 风格的算法和 encoders在 Controller 中是到达那里的唯一方法吗?

最佳答案

结帐 https://github.com/FriendsOfSymfony/FOSRestBundle , 部分“格式监听器”...

关于rest - 内容协商 ("Accept"HTTP header )基于 symfony2.0 中的路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8473394/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com