jooby/src/main/java/org/jooby/Results.java
@Nonnull
  public static Result when(final String type, final Supplier<Object> supplier) {
    return new Result().when(type, supplier);
  }
@Nonnull
  public static Result when(final String type, final Supplier<Object> supplier) {
    return new Result().when(type, supplier);
  }
@ Nonnull public static Result when ( final String type , final Supplier < Object > supplier ) { return new Result ( ) . when ( type , supplier ) ; }
Performs content-negotiation on the Accept HTTP header on the request object. It select a
handler for the request, based on the acceptable types ordered by their quality values.
If the header is not specified, the first callback is invoked. When no match is found,
the server responds with 406 "Not Acceptable", or invokes the default callback: {@code ** / *}.

<pre>
get("/jsonOrHtml", () {@literal ->}
Results
.when("text/html", () {@literal ->} Results.html("view").put("model", model)))
.when("application/json", () {@literal ->} model)
.when("*", () {@literal ->} {throw new Err(Status.NOT_ACCEPTABLE);})
);
</pre>

@param type A media type.
@param supplier A result supplier.
@return A new result.
Performs content - negotiation on the Accept HTTP header on the request object . It select a handler for the request based on the acceptable types ordered by their quality values . If the header is not specified the first callback is invoked . When no match is found the server responds with 406 Not Acceptable or invokes the default callback : { @code ** / * } .