Created
November 23, 2009 07:03
-
-
Save ryanbriones/240942 to your computer and use it in GitHub Desktop.
first pass at what my sinatra-like java servlet would look like
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.sinatraLikeServlet.*; | |
public class MyApplication extends SinatraLikeHTTPServlet { | |
@get("/") | |
public void index(SinatraLikeHTTPServletRequest req | |
SinatraLikeHTTPServletResponse resp) { | |
MyResource[] resources = MyResource.findAll(); | |
req.setAttribute("resources", resources); | |
} | |
@get("/:id") | |
public void show(SinatraLikeHTTPServletRequest req | |
SinatraLikeHTTPServletResponse resp) { | |
String myResourceId = request.getParameter("id"); | |
MyResource resource = MyResource.find(myResourceId); | |
req.setAttribute("resource", resource); | |
} | |
@get("/:id") | |
@provides("json") | |
public String show(SinatraLikeHTTPServletRequest req | |
SinatraLikeHTTPServletResponse resp) { | |
String myResourceId = request.getParameter("id"); | |
MyResource resource = MyResource.find(myResourceId); | |
return resource.toJson(); | |
} | |
} |
It didn't actually. This was just a "proposed" API. I showed it to a friend who was more well-versed in Java Servlets and he said he wanted to take a stab at it, but I don't think he ever did. I would love to see this become a reality though.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did this ever see the light of day? Would love to be able to use this on a project.