* @return {JsonObject} session
*/
public JsonObject createSession(@NotNull final String sessionId) {
final JsonObject session = new JsonObject().putString("id", sessionId);
put("session", new SessionObject(session, true));
response().headersHandler(new Handler<Void>() {
@Override
public void handle(Void event) {
int responseStatus = response().getStatusCode();
// Only save on success and redirect status codes
if (responseStatus >= 200 && responseStatus < 400) {
SessionObject session = get("session");
if (session != null && session.isChanged()) {
store.set(sessionId, session.jsonObject(), new Handler<Object>() {
@Override
public void handle(Object error) {
if (error != null) {
// TODO: better handling of errors
System.err.println(error);