import akka.actor.ActorSystem; import akka.http.javadsl.Http; import akka.http.javadsl.server.AllDirectives; import akka.http.javadsl.server.Route; public class SimpleHttpServer extends AllDirectives { public static void main(String[] args) throws Exception { ActorSystem system = ActorSystem.create("simpleHttpServer"); Http http = Http.get(system); final SimpleHttpServer server = new SimpleHttpServer(); final Route route = path("hello", () -> get(() -> complete("<h1>Hello, Akka HTTP!</h1>") ) ); http.bindAndHandle(route.flow(system, materializer), ConnectHttp.toHost("localhost", 8080), materializer); } }


上一篇:
下一篇:
切换中文