// Creating a minimal handler returning "Hello World"
UniformInterface handler = new UniformInterface() {
public void handle(UniformCall call) {
call.setOutput(new StringRepresentation("Hello World!",
MediaTypes.TEXT_PLAIN));
}
};
// Create the HTTP server and listen on port 8182
new JettyServer("My Web server", 8182, handler).start();
If you run this code and launch your server, you can open a Web browser and hit the http://localhost:8182. Actually, any URI will work, try also http://localhost:8182/test/tutorial. This handler is very primitive and only takes advantage of the pure REST part of the Restlet framework. Later in the tutorial, we can see how to take advantage of the Restlets in order to facilitate this processing.
No comments:
Post a Comment