#1389·go-swagger

Is it possible to change producer in server depending on client request parameter?

Author: aalexanderrCreated Jan 26, 2018Updated Jun 28, 2026
Labelsquestiondocmedia types

Problem statement

I'd like for my API to be able to be able to respond in both json and xml, for that I need to change producer depending on a query parameter contents. I can't find how to do it, is it possible? If so, could I ask for some guidance what should I look at? Producer is set by the WriteResponse function, but how do I pass a producer to this function (from handler scope)

Swagger specification

anything where

yaml
produces:
- application/json
- application/xml

Environment

swagger version: dev go version: 1.9.2 OS: n/a