Skip to content

API change: Replace Response.Formatter and Viewable annotation with Result #52

@jknack

Description

@jknack

Content negotiation was done via Response.Formatter:

get("/", (req, rsp) -> {
  return rsp.format()
     .when("text/html", () -> View.of("view", "model", new Model())
     .when("application/json", () -> new Model());
});

After this change:

get("/", req -> {
  return Results
     .when("text/html", () -> View.of("view", "model", new Model())
     .when("application/json", () -> new Model());
});

With Mvc Routes:

public class Mvc {

  @Viewable("view")
  @Path("/") @GET
  public Model mvc() {
    return new Model();
  }
}

Now:

public class Mvc {

  @Path("/") @GET
  public Result mvc() {
    return Results
      .when("text/html", () -> View.of("view", "model", new Model())
      .when("application/json", () -> new Model());
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions