Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert form urlencoded and multipart/data body as a bean/interface #8

Closed
jknack opened this issue Dec 6, 2014 · 0 comments
Closed
Milestone

Comments

@jknack
Copy link
Member

jknack commented Dec 6, 2014

req params/headers can be injected in any of these classes:

  • interface
public interface Person {
  String name();

  int age();
}
  • class with public constructor
public class Person {
  public final String name;

  public final int age;

  public Person(String name, int age) {
   this.name = name;
   this.age = age;
  }
}
  • class with no-arg constructor
public class Person {
  private String name;

  private int age;

  public String name() {
    return name;
  }

 public int age() {
    return age;
  }
}

retrieval is done using the req.body or req.params method:

// POST or PUT
Person person = req.body(Person.class);

// GET, etc.
Person person = req.params(Person.class);

or from MVC method

    @GET
    public Object params(Person person) {
      ...
    }

  @POST
    public Object body(Person person) {
      ...
    }
@jknack jknack added this to the 0.3.0 milestone Dec 6, 2014
@jknack jknack changed the title inject request params/headers into bean class or interface convert form urlencoded and multipart/data body as a bean/interface Dec 10, 2014
@jknack jknack closed this as completed in 3f4ad4b Dec 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant