try to add a http server
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
package ro.mihai;
|
||||
|
||||
import com.twitter.finagle.Service;
|
||||
import com.twitter.finagle.http.Http;
|
||||
import com.twitter.util.Future;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
Service<HttpRequest, HttpResponse> service = new Service<HttpRequest, HttpResponse>() {
|
||||
public Future<HttpResponse> apply(HttpRequest request) {
|
||||
return Future.value(
|
||||
new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK));
|
||||
}
|
||||
};
|
||||
|
||||
ServerBuilder.safeBuild(service, ServerBuilder.get()
|
||||
.codec(Http())
|
||||
.name("HttpServer")
|
||||
.bindTo(new InetSocketAddress("localhost", 5151)));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user