本文整理了Java中org.jooby.Request.set
方法的一些代码示例,展示了Request.set
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.set
方法的具体详情如下:
包路径:org.jooby.Request
类名称:Request
方法名:set
[英]Seed a RequestScoped object.
[中]为RequestScope对象设定种子。
代码示例来源:origin: jooby-project/jooby
@Override
public Request set(final TypeLiteral<?> type, final Object value) {
req.set(type, value);
return this;
}
代码示例来源:origin: jooby-project/jooby
@Override
public Request set(final String name, final Object value) {
req.set(name, value);
return this;
}
代码示例来源:origin: jooby-project/jooby
@Override
public Request set(final Class<?> type, final Object value) {
req.set(type, value);
return this;
}
代码示例来源:origin: jooby-project/jooby
@Override
public Request set(final Key<?> key, final Object value) {
req.set(key, value);
return this;
}
代码示例来源:origin: jooby-project/jooby
@Override
public void setRequestAttribute(final String name, final Object value) {
req.set(name, value);
}
代码示例来源:origin: jooby-project/jooby
@Override public void setRequestAttribute(String name, Object value) {
req.set(name, value);
}
代码示例来源:origin: jooby-project/jooby
@SuppressWarnings("rawtypes")
private void seed(final Request req, Class type, final Object profile) {
while (type != Object.class) {
req.set(type, profile);
type = type.getSuperclass();
}
}
代码示例来源:origin: jooby-project/jooby
/**
* Seed a {@link RequestScoped} object.
*
* @param type Seed type.
* @param value Actual object to bind.
* @return Current request.
*/
@Nonnull
default Request set(final TypeLiteral<?> type, final Object value) {
return set(Key.get(type), value);
}
代码示例来源:origin: jooby-project/jooby
/**
* Seed a {@link RequestScoped} object.
*
* @param type Object type.
* @param value Actual object to bind.
* @return Current request.
*/
@Nonnull
default Request set(final Class<?> type, final Object value) {
return set(TypeLiteral.get(type), value);
}
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final Request req, final Response rsp) {
compiler.fileset().forEach(asset -> {
/** Styles */
List<String> css = this.styles.apply(asset);
String styles = css.stream().reduce(new StringBuilder(),
(buff, it) -> buff.append("<link href=\"")
.append(cpath)
.append(it)
.append("\" rel=\"stylesheet\">\n"),
StringBuilder::append)
.toString();
req.set(asset + "_css", css);
req.set(asset + "_styles", styles);
/** Scripts */
List<String> js = this.scripts.apply(asset);
String scripts = js.stream().reduce(new StringBuilder(),
(buff, it) -> buff.append("<script src=\"")
.append(cpath)
.append(it)
.append("\"></script>\n"),
StringBuilder::append)
.toString();
req.set(asset + "_js", js);
req.set(asset + "_scripts", scripts);
});
}
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final Request req, final Response rsp) throws Throwable {
String error = req.param("error").value("");
String username = req.param("username").value("");
req.set("username", username);
req.set("error", error);
// default login form
rsp.type(MediaType.html).send(String.format(FORM, error, callback, username));
}
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final Request req, final Response rsp, final Chain chain) throws Throwable {
String error = req.param("error").toOptional().orElse("");
String username = req.param("username").toOptional().orElse("");
req.set("username", username);
req.set("error", error);
if (loginUrl.equals(req.path())) {
// default login form
rsp.type(MediaType.html).send(String.format(FORM, error, callback, username));
} else {
super.handle(req, rsp, chain);
}
}
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final Request req, final Response rsp, final Route.Chain chain)
throws Throwable {
Optional<String> value = req.cookie(cname).toOptional();
Map<String, String> source = value.map(decoder::apply)
.orElseGet(HashMap::new);
FlashMap flashScope = new FlashMap(source);
req.set(FlashScope.NAME, flashScope);
// wrap & proceed
rsp.after(finalizeFlash(source, flashScope));
chain.next(req, rsp);
}
代码示例来源:origin: jooby-project/jooby
@Override public void handle(final Request req, final Response rsp, final Route.Chain chain)
throws Throwable {
logger.debug("open handle");
Handle handle = jdbi.open();
Optional.ofNullable(trx.configurer).ifPresent(c -> c.accept(handle));
req.set(trx.handle(), handle);
logger.debug("new transaction: {}", handle);
handle.begin();
rsp.after(new CommitTransaction(handle));
rsp.complete(new RollbackTransaction(handle));
rsp.complete(new CloseHandle(handle));
chain.next(req, rsp);
}
}
代码示例来源:origin: jooby-project/jooby
@Override
public void handle(final Request req, final Response rsp, final Route.Chain chain)
throws Throwable {
/**
* Get or generate a token
*/
Session session = req.session();
String token = session.get(name).toOptional().orElseGet(() -> {
String newToken = generator.apply(req);
session.set(name, newToken);
return newToken;
});
req.set(name, token);
if (requireToken.test(req)) {
String candidate = req.header(name).toOptional()
.orElseGet(() -> req.param(name).toOptional().orElse(null));
if (!token.equals(candidate)) {
throw new Err(Status.FORBIDDEN, "Invalid Csrf token: " + candidate);
}
}
chain.next(req, rsp);
}
}
代码示例来源:origin: jooby-project/jooby
router.assets("/livereload.js", livereloadjs);
router.use("*", (req, rsp) -> req.set("liveReload", template(req)))
.name("livereload");
代码示例来源:origin: jooby-project/jooby
if (profile != null) {
String id = profile.getId();
req.set(Auth.ID, id);
session.set(Auth.ID, id);
store.set(profile);
代码示例来源:origin: jooby-project/jooby
log.debug("profile: {}", identity);
if (identity != null) {
req.set(Auth.ID, identity.getId());
req.set(Auth.CNAME, client.getName());
store.set(identity);
代码示例来源:origin: org.jooby/jooby
@Override
public Request set(final String name, final Object value) {
req.set(name, value);
return this;
}
代码示例来源:origin: org.jooby/jooby
@Override
public Request set(final TypeLiteral<?> type, final Object value) {
req.set(type, value);
return this;
}
内容来源于网络,如有侵权,请联系作者删除!