gpt4 book ai didi

com.jetdrone.vertx.yoke.middleware.YokeRequest.createSession()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 12:20:40 26 4
gpt4 key购买 nike

本文整理了Java中com.jetdrone.vertx.yoke.middleware.YokeRequest.createSession()方法的一些代码示例,展示了YokeRequest.createSession()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YokeRequest.createSession()方法的具体详情如下:
包路径:com.jetdrone.vertx.yoke.middleware.YokeRequest
类名称:YokeRequest
方法名:createSession

YokeRequest.createSession介绍

[英]Create a new Session and store it with the underlying storage. Internally create a entry in the request context under the name "session" and add a end handler to save that object once the execution is terminated.
[中]创建一个新会话并将其与基础存储一起存储。在请求上下文中内部创建一个名为“session”的条目,并添加一个结束处理程序,以便在执行终止后保存该对象。

代码示例

代码示例来源:origin: pmlopes/yoke

/** Create a new Session and store it with the underlying storage.
 * Internally create a entry in the request context under the name "session" and add a end handler to save that
 * object once the execution is terminated.
 *
 * @return {JsonObject} session
 */
public JsonObject createSession() {
  final String sessionId = UUID.randomUUID().toString();
  return createSession(sessionId);
}

代码示例来源:origin: pmlopes/yoke

@Override
  public void handle(JsonObject user) {
    if (user != null) {
      JsonObject session = request.createSession();
      session.put("user", request.getFormAttribute("username"));
      // get the redirect_url parameter
      String redirect = request.getParam("redirect_url", "/");
      request.response().redirect(Utils.decodeURIComponent(redirect));
    } else {
      if (loginTemplate != null) {
        // render internal login
        request.response().setContentType("text/html");
        request.response().setStatusCode(401);
        request.response().end(
            loginTemplate.replace("{title}", (String) request.get("title"))
                .replace("{action}", loginURI + "?redirect_url=" + Utils.encodeURIComponent(request.getParam("redirect_url", "/")))
                .replace("{message}", "Invalid username and/or password, please try again."));
      } else {
        next.handle(401);
      }
    }
  }
});

代码示例来源:origin: pmlopes/yoke

next.handle(null);
} else {
  session = request.createSession();

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com