开发者

Grails Content Negotiation - handling unsupported type

开发者 https://www.devze.com 2023-01-14 08:17 出处:网络
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

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

精彩评论

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