D
D
demoontz2015-03-28 14:40:59
Java
demoontz, 2015-03-28 14:40:59

Correct java+rest server example?

Greetings! I am writing a server for a mobile application using javaee + rest. I'm looking for some nicely/correctly written code for REST with templates and other jokes. I would also like to do my code correctly too.
If you have anything in mind? on github for example.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Timur, 2015-03-28
@timych

docs.oracle.com/javaee/7/tutorial/jaxrs.htm#GIEPU
These are the docks. (The full book is also available in PDF)
resteasy.jboss.org
This is the implementation that many people use.
In the downloads section "Documentation" there is a mountain of examples to download.
True, I almost did not use them - I spied on more experienced colleagues at work :)

D
demoontz, 2015-03-28
@demoontz

I have looked at these examples. There are enough of them in the Internet, according to the word example. but it does not suit me, because it has nothing to do with the real product. I expect to see logging, error handling, caching maybe, ssl, maybe some patterns and maybe something else. I'm looking for information like this.
for example here is my piece of code. I'm sure it can be better.

@GET
  @Path("/login")
  // @Consumes(MediaType.APPLICATION_JSON)
  @Produces(MediaType.APPLICATION_JSON)
  public Response login(@QueryParam("email") String email, @QueryParam("pass") String pass, @QueryParam("stag") String sTag) {
    log.info("login");
    Response response = null;
    User u = userM.login(email, pass, sTag);
    System.out.println(u);
    if (u != null) {
      response = Response.ok().entity(u).build();
    } else
      response = Response.serverError().status(401).build();
    return response;

  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question