java.lang.IllegalStateException: Request has already been read
package io.vertx.example.web.sessions;
import io.vertx.core.AbstractVerticle;import io.vertx.core.http.HttpClientRequest;import io.vertx.core.http.HttpMethod;import io.vertx.core.http.HttpServerRequest;import io.vertx.example.util.Runner;import io.vertx.ext.web.Router;import io.vertx.ext.web.Session;import io.vertx.ext.web.handler.CookieHandler;import io.vertx.ext.web.handler.SessionHandler;import io.vertx.ext.web.sstore.ClusteredSessionStore;import io.vertx.ext.web.sstore.LocalSessionStore;
/* * @author <a href="http://tfox.org">Tim Fox</a> */public class Server extends AbstractVerticle {
// Convenience method so you can run it in your IDE public static void main(String[] args) { Runner.runClusteredExample(Server.class); }
@Override public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(CookieHandler.create()); router.route().handler(SessionHandler.create(ClusteredSessionStore.create(vertx)));
router.route().handler(routingContext -> {
Session session = routingContext.session();
HttpServerRequest req = routingContext.request(); req.endHandler(aVoid -> { Integer cnt = session.get("hitcount"); cnt = (cnt == null ? 0 : cnt) + 1;
session.put("hitcount", cnt);
routingContext.response().putHeader("content-type", "text/html") .end("<html><body><h1>Hitcount: " + cnt + "</h1></body></html>");
});
});
vertx.createHttpServer().requestHandler(router::accept).listen(8080); }}
--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
Visit this group at http://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/a75eae84-6978-4bbe-8d70-12b3d182c475%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/4d0d273f-c33f-496d-b1fc-1ccc90c99ae7%40googlegroups.com.
public class Server extends AbstractVerticle {
// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runClusteredExample(Server.class);
}
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(ClusteredSessionStore.create(vertx)));
router.route().handler(routingContext -> {
Session session = routingContext.session();
HttpServerRequest req = routingContext.request();
req.endHandler(aVoid -> {
String id = session.id();
req.response().end("your session id is " + id);
});
});
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
}
public class Server extends AbstractVerticle {
// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runClusteredExample(Server.class);
}
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(ClusteredSessionStore.create(vertx)));
router.route().handler(routingContext -> {
HttpServerRequest req = routingContext.request();
req.endHandler(aVoid -> {
req.response().end("finished");
});
});
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
}
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/3f46d03e-020c-42ca-883a-e096df244621%40googlegroups.com.
public class Server extends AbstractVerticle {
// Convenience method so you can run it in your IDE
public static void main(String[] args) {
Runner.runClusteredExample(Server.class);
}
@Override
public void start() throws Exception {
Router router = Router.router(vertx);
router.route().handler(CookieHandler.create());
router.route().handler(SessionHandler.create(ClusteredSessionStore.create(vertx)));
router.route().handler(routingContext -> {
HttpServerRequest req = routingContext.request();
req.bodyHandler(aVoid -> {
req.response().end("finished");
});
});
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
}To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/57a7cbb9-b88c-4c30-87f4-9b24c60d9362%40googlegroups.com.
...