加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – FOSRestBundle – 只允许json xml,如果没有其他请求则默

发布时间:2020-12-13 18:17:35 所属栏目:PHP教程 来源:网络整理
导读:有人可以给我看一个FOSRestBundle的参考配置,如果没有设置“Accepted”或“Content-Type”,它只允许json xml和willd默认为json. 我的目标是删除模板html支持和所有其他不必要的格式(在我的情况下). 提前致谢! 得到它了. # app/config/config.yml# ...fos_re
有人可以给我看一个FOSRestBundle的参考配置,如果没有设置“Accepted”或“Content-Type”,它只允许json xml和willd默认为json.

我的目标是删除模板html支持和所有其他不必要的格式(在我的情况下).

提前致谢!

得到它了.
# app/config/config.yml
# ...
fos_rest:
    routing_loader:
        default_format: json
        include_format: true
    param_fetcher_listener: force
    body_listener: true
    allowed_methods_listener: true
    view:
        view_response_listener: 'force'
        formats:
            json: true
            xml: true
    format_listener:
        rules:
            - { path: '^/api',priorities: ['json','xml'],fallback_format: json,prefer_extension: true }

sensio_framework_extra:
    view:    { annotations: false }
    router:  { annotations: true }
# ...

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读