Content negotiation
According to HTTP:
Content negotiation is the process of selecting the best representation for a given response when there are multiple representations available.
It can either be server-driven or agent-driven or a combination of both, which is called transparent negotiation. Play provides support for server-driven negotiations. This is handled by the rendering trait and is extended by the controller trait. The controller trait is the one where the controller objects in a Play app extend.
Let's look at the Rendering
trait:
trait Rendering { object render { //Tries to render the most acceptable result according to the request's Accept header value. def apply(f: PartialFunction[MediaRange, Result])(implicit request: RequestHeader): ...
Get Mastering Play Framework for Scala now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.