开发者

Grails Content Negotiation - handling unsupported type

We are using content negotiation in our service using the Accept header and the withFo开发者_如何转开发rmat method....the issue we are facing is that we want to return a 406 http status if the Accept header has a type which is not supported by our service....can anybody give us some ideas on how would we go about doing this?


  return withFormat {
     html {
        render(view: "itWorked", model: data)
     }
     json {
        render(data as JSON)
     }
     xml {
        render(data as XML)
     }
  }

  render(status: 406, text: 'ERROR')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜