Package mjg

Source Code of mjg.HelloRestlet

package mjg;

import org.restlet.Request;
import org.restlet.Response;
import org.restlet.Restlet;
import org.restlet.Server;
import org.restlet.data.MediaType;
import org.restlet.data.Protocol;
import org.restlet.resource.ClientResource;

public class HelloRestlet {
  public static void main(String[] args) throws Exception {
    Server server = new Server(Protocol.HTTP, 8182, new Restlet() {
      @Override
      public void handle(Request request, Response response) {
        response.setEntity("Hello, World", MediaType.TEXT_PLAIN);
      }
    });
   
    server.start();
   
    new ClientResource("http://localhost:8182").get().write(System.out);
   
    server.stop();
  }
}
TOP

Related Classes of mjg.HelloRestlet

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.