org.jooby.Request.set()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(397)

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

Request.set介绍

[英]Seed a RequestScoped object.
[中]为RequestScope对象设定种子。

代码示例

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public Request set(final TypeLiteral<?> type, final Object value) {
  3. req.set(type, value);
  4. return this;
  5. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public Request set(final String name, final Object value) {
  3. req.set(name, value);
  4. return this;
  5. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public Request set(final Class<?> type, final Object value) {
  3. req.set(type, value);
  4. return this;
  5. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public Request set(final Key<?> key, final Object value) {
  3. req.set(key, value);
  4. return this;
  5. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public void setRequestAttribute(final String name, final Object value) {
  3. req.set(name, value);
  4. }

代码示例来源:origin: jooby-project/jooby

  1. @Override public void setRequestAttribute(String name, Object value) {
  2. req.set(name, value);
  3. }

代码示例来源:origin: jooby-project/jooby

  1. @SuppressWarnings("rawtypes")
  2. private void seed(final Request req, Class type, final Object profile) {
  3. while (type != Object.class) {
  4. req.set(type, profile);
  5. type = type.getSuperclass();
  6. }
  7. }

代码示例来源:origin: jooby-project/jooby

  1. /**
  2. * Seed a {@link RequestScoped} object.
  3. *
  4. * @param type Seed type.
  5. * @param value Actual object to bind.
  6. * @return Current request.
  7. */
  8. @Nonnull
  9. default Request set(final TypeLiteral<?> type, final Object value) {
  10. return set(Key.get(type), value);
  11. }

代码示例来源:origin: jooby-project/jooby

  1. /**
  2. * Seed a {@link RequestScoped} object.
  3. *
  4. * @param type Object type.
  5. * @param value Actual object to bind.
  6. * @return Current request.
  7. */
  8. @Nonnull
  9. default Request set(final Class<?> type, final Object value) {
  10. return set(TypeLiteral.get(type), value);
  11. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public void handle(final Request req, final Response rsp) {
  3. compiler.fileset().forEach(asset -> {
  4. /** Styles */
  5. List<String> css = this.styles.apply(asset);
  6. String styles = css.stream().reduce(new StringBuilder(),
  7. (buff, it) -> buff.append("<link href=\"")
  8. .append(cpath)
  9. .append(it)
  10. .append("\" rel=\"stylesheet\">\n"),
  11. StringBuilder::append)
  12. .toString();
  13. req.set(asset + "_css", css);
  14. req.set(asset + "_styles", styles);
  15. /** Scripts */
  16. List<String> js = this.scripts.apply(asset);
  17. String scripts = js.stream().reduce(new StringBuilder(),
  18. (buff, it) -> buff.append("<script src=\"")
  19. .append(cpath)
  20. .append(it)
  21. .append("\"></script>\n"),
  22. StringBuilder::append)
  23. .toString();
  24. req.set(asset + "_js", js);
  25. req.set(asset + "_scripts", scripts);
  26. });
  27. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public void handle(final Request req, final Response rsp) throws Throwable {
  3. String error = req.param("error").value("");
  4. String username = req.param("username").value("");
  5. req.set("username", username);
  6. req.set("error", error);
  7. // default login form
  8. rsp.type(MediaType.html).send(String.format(FORM, error, callback, username));
  9. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public void handle(final Request req, final Response rsp, final Chain chain) throws Throwable {
  3. String error = req.param("error").toOptional().orElse("");
  4. String username = req.param("username").toOptional().orElse("");
  5. req.set("username", username);
  6. req.set("error", error);
  7. if (loginUrl.equals(req.path())) {
  8. // default login form
  9. rsp.type(MediaType.html).send(String.format(FORM, error, callback, username));
  10. } else {
  11. super.handle(req, rsp, chain);
  12. }
  13. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public void handle(final Request req, final Response rsp, final Route.Chain chain)
  3. throws Throwable {
  4. Optional<String> value = req.cookie(cname).toOptional();
  5. Map<String, String> source = value.map(decoder::apply)
  6. .orElseGet(HashMap::new);
  7. FlashMap flashScope = new FlashMap(source);
  8. req.set(FlashScope.NAME, flashScope);
  9. // wrap & proceed
  10. rsp.after(finalizeFlash(source, flashScope));
  11. chain.next(req, rsp);
  12. }

代码示例来源:origin: jooby-project/jooby

  1. @Override public void handle(final Request req, final Response rsp, final Route.Chain chain)
  2. throws Throwable {
  3. logger.debug("open handle");
  4. Handle handle = jdbi.open();
  5. Optional.ofNullable(trx.configurer).ifPresent(c -> c.accept(handle));
  6. req.set(trx.handle(), handle);
  7. logger.debug("new transaction: {}", handle);
  8. handle.begin();
  9. rsp.after(new CommitTransaction(handle));
  10. rsp.complete(new RollbackTransaction(handle));
  11. rsp.complete(new CloseHandle(handle));
  12. chain.next(req, rsp);
  13. }
  14. }

代码示例来源:origin: jooby-project/jooby

  1. @Override
  2. public void handle(final Request req, final Response rsp, final Route.Chain chain)
  3. throws Throwable {
  4. /**
  5. * Get or generate a token
  6. */
  7. Session session = req.session();
  8. String token = session.get(name).toOptional().orElseGet(() -> {
  9. String newToken = generator.apply(req);
  10. session.set(name, newToken);
  11. return newToken;
  12. });
  13. req.set(name, token);
  14. if (requireToken.test(req)) {
  15. String candidate = req.header(name).toOptional()
  16. .orElseGet(() -> req.param(name).toOptional().orElse(null));
  17. if (!token.equals(candidate)) {
  18. throw new Err(Status.FORBIDDEN, "Invalid Csrf token: " + candidate);
  19. }
  20. }
  21. chain.next(req, rsp);
  22. }
  23. }

代码示例来源:origin: jooby-project/jooby

  1. router.assets("/livereload.js", livereloadjs);
  2. router.use("*", (req, rsp) -> req.set("liveReload", template(req)))
  3. .name("livereload");

代码示例来源:origin: jooby-project/jooby

  1. if (profile != null) {
  2. String id = profile.getId();
  3. req.set(Auth.ID, id);
  4. session.set(Auth.ID, id);
  5. store.set(profile);

代码示例来源:origin: jooby-project/jooby

  1. log.debug("profile: {}", identity);
  2. if (identity != null) {
  3. req.set(Auth.ID, identity.getId());
  4. req.set(Auth.CNAME, client.getName());
  5. store.set(identity);

代码示例来源:origin: org.jooby/jooby

  1. @Override
  2. public Request set(final String name, final Object value) {
  3. req.set(name, value);
  4. return this;
  5. }

代码示例来源:origin: org.jooby/jooby

  1. @Override
  2. public Request set(final TypeLiteral<?> type, final Object value) {
  3. req.set(type, value);
  4. return this;
  5. }

相关文章