# What's the best way to response with different format when requesting the same URL with diffrent Content-Type

**URL:** <https://discourse.laminas.dev/t/whats-the-best-way-to-response-with-different-format-when-requesting-the-same-url-with-diffrent-content-type/2433>\
**Category:** Components & MVC\
**Tags:** laminas-mvc\
**Created:** [August 6, 2021, 7:47am UTC](https://discourse.laminas.dev/t/whats-the-best-way-to-response-with-different-format-when-requesting-the-same-url-with-diffrent-content-type/2433 "2021-08-06T07:47:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jobsfan](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jobsfan/32/399_2.png) [@jobsfan](https://discourse.laminas.dev/u/jobsfan)\
**Post date:** [August 6, 2021, 7:47am UTC](https://discourse.laminas.dev/t/whats-the-best-way-to-response-with-different-format-when-requesting-the-same-url-with-diffrent-content-type/2433/1 "2021-08-06T07:47:36Z")

</div>

I am using laminas-mvc, when requesting /appliation/index/demo with **Content-Type: application/json** , then I response with json format, when xml then response xml format, if not specially set the content-type, when It will response a html format.

I am wondering how to fulfil this condition. Or where is the best place to hook the logic.  
I don’t know if anyone have done this before. any advises?

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [August 6, 2021, 7:55am UTC](https://discourse.laminas.dev/t/whats-the-best-way-to-response-with-different-format-when-requesting-the-same-url-with-diffrent-content-type/2433/2 "2021-08-06T07:55:52Z")

</div>

Please check the controller plugin “[AcceptableViewModelSelector](https://docs.laminas.dev/laminas-mvc/plugins/#acceptableviewmodelselector-plugin)”.

---

<div class="post-metadata">

**Author:** ![jobsfan](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/jobsfan/32/399_2.png) [@jobsfan](https://discourse.laminas.dev/u/jobsfan)\
**Post date:** [August 6, 2021, 7:58am UTC](https://discourse.laminas.dev/t/whats-the-best-way-to-response-with-different-format-when-requesting-the-same-url-with-diffrent-content-type/2433/3 "2021-08-06T07:58:05Z")

</div>

thank you! it seems exactly what I am looking for!!
