import io.activej.eventloop.Eventloop; import io.activej.http.*; import io.activej.launchers.http.HttpServerLauncher; public class MyHttpServerLauncher extends HttpServerLauncher { @Override protected HttpServer createHttpServer(Eventloop eventloop) { return HttpServer.create(eventloop, router -> { router.get("/", request -> HttpResponse.ok200().withPlainText("Hello, ActiveJ!")); router.get("/users/:id", request -> { String userId = request.getPathParameter("id"); return HttpResponse.ok200().withPlainText("User ID: " + userId); }); }); } public static void main(String[] args) throws Exception { MyHttpServerLauncher launcher = new MyHttpServerLauncher(); launcher.launch(args); } }


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