gpt4 book ai didi

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

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

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

YokeRequest.get介绍

[英]Allow getting properties in a generified way.
[中]允许以通用方式获取属性。

代码示例

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

@Override
public void setSessionAttribute(String name, Object value) {
  JsonObject session = request.get("session");
  session.put(name, value);
}

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

@Override
  public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
    JsonObject session = request.get("session");
    if (session != null) {
      if (session.getString("id") != null) {
        next.handle(null);
        return;
      }
    }
    String redirect = request.getParam("redirect_url", Utils.encodeURIComponent(request.uri()));
    request.response().redirect(loginURI + "?redirect_url=" + Utils.decodeURIComponent(redirect));
  }
};

代码示例来源: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

return request.get(path);
case 4:
  return request.getHeader(path);

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

@Override
public Object getSessionAttribute(String name) {
  JsonObject session = request.get("session");
  return session.getValue(name);
}

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

loginTemplate.replace("{title}", (String) request.get("title"))
    .replace("{action}", loginURI + "?redirect_url=" + Utils.encodeURIComponent(request.getParam("redirect_url", "/")))
    .replace("{message}", ""));

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

/** Allow getting properties in a generified way and return defaultValue if the key does not exist.
 *
 * @param name The key to get
 * @param defaultValue value returned when the key does not exist
 * @return {R} The found object
 */
public <R> R get(@NotNull final String name, R defaultValue) {
  if (context.containsKey(name)) {
    return get(name);
  } else {
    return defaultValue;
  }
}

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

/** Destroys a session from the request context and also from the storage engine.
 */
public void destroySession() {
  JsonObject session = get("session");
  if (session == null) {
    return;
  }
  String sessionId = session.getString("id");
  // remove from the context
  put("session", null);
  if (sessionId == null) {
    return;
  }
  store.destroy(sessionId, new Handler<Object>() {
    @Override
    public void handle(Object error) {
      if (error != null) {
        // TODO: better handling of errors
        System.err.println(error);
      }
    }
  });
}

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

.put("value", item);
final JsonObject userFilter = request.get("filter");

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

.put("query", new JsonObject().put(key, id));
final JsonObject userFilter = request.get("filter");

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

return;
  if (!request.get("canceled", false)) {
    next.handle(null);
    request.setBody(null);
    if (!request.get("canceled", false)) {
      next.handle(null);
  request.setBody(buffer);
if (!request.get("canceled", false)) {
  next.handle(null);

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

.put("query", new JsonObject().put(key, id));
final JsonObject userFilter = request.get("filter");

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

errorTemplate.replace("{title}", request.get("title"))
    .replace("{errorCode}", Integer.toString(errorCode))
    .replace("{errorMessage}", errorMessage == null ? "" : errorMessage)

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

.put("query", new JsonObject().put(key, id));
final JsonObject userFilter = request.get("filter");

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

@Override
public void handle(@NotNull final YokeRequest request, @NotNull final Handler<Object> next) {
  String token = request.get(key);
  // generate CSRF token
  if (token == null) {
    token = UUID.randomUUID().toString();
    request.put(key, token);
  }
  // ignore these methods
  if (HttpMethod.GET.equals(request.method()) || HttpMethod.HEAD.equals(request.method()) || HttpMethod.OPTIONS.equals(request.method())) {
    next.handle(null);
    return;
  }
  // expect multipart
  request.setExpectMultipart(true);
  // determine value
  String val = valueHandler.handle(request);
  // check
  if (!token.equals(val)) {
    next.handle(403);
    return;
  }
  // OK
  next.handle(null);
}

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

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

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

response.setStatusCode(getErrorCode(request.get("error")));
if (request.get("error") == null) {
  request.put("error", response.getStatusCode());
String errorMessage = getMessage(request.get("error"));
int errorCode = response.getStatusCode();
List<String> stackTrace = getStackTrace(request.get("error"));

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

@Override
  public void handle(Void done) {
    JsonObject session = request.get("session");
    String sessionId = session == null ? null : session.getString("id");
    // removed
    if (sessionId == null) {
      if (sessionCookie != null) {
        cookie.setValue("");
        cookie.setMaxAge(0);
        response.addCookie(cookie);
      }
    } else {
      // only send secure cookies over https
      if (cookie.isSecure() && !request.isSSL()) {
        return;
      }
      // compare hashes, no need to set-cookie if unchanged
      if (originalHash != crc16(sessionId)) {
        // modified session
        cookie.setValue(sessionId);
        cookie.sign();
        response.addCookie(cookie);
      }
    }
  }
});

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

Boolean poweredBy = request.get("x-powered-by");
if (poweredBy != null && poweredBy) {
  request.response().putHeader("x-powered-by", "yoke");

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

@Override
public void handle(@NotNull YokeRequest request, @NotNull Handler<Object> next) {
  JsonObject session = request.get("session");

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