本文整理了Java中spark.Request.attribute
方法的一些代码示例,展示了Request.attribute
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.attribute
方法的具体详情如下:
包路径:spark.Request
类名称:Request
方法名:attribute
[英]Gets the value of the provided attribute
[中]获取所提供属性的值
代码示例来源:origin: perwendel/spark
@Override
public void attribute(String attribute, Object value) {
delegate.attribute(attribute, value);
}
代码示例来源:origin: perwendel/spark
@Override
public <T> T attribute(String attribute) {
return delegate.attribute(attribute);
}
代码示例来源:origin: gocd/gocd
public void init() {
before("/*", (request, response) -> request.attribute(TIMER_START, new RuntimeHeaderEmitter(request, response)));
before("/*", (request, response) -> response.header("Cache-Control", "max-age=0, private, must-revalidate"));
controllers.forEach(SparkSpringController::setupRoutes);
sparkControllers.forEach(SparkController::setupRoutes);
exception(JsonParseException.class, this::invalidJsonPayload);
exception(UnprocessableEntityException.class, this::unprocessableEntity);
afterAfter("/*", (request, response) -> request.<RuntimeHeaderEmitter>attribute(TIMER_START).render());
}
代码示例来源:origin: openzipkin/brave
public Filter before() {
return (request, response) -> {
Span span = handler.handleReceive(extractor, request, request.raw());
request.attribute(Tracer.SpanInScope.class.getName(), tracer.withSpanInScope(span));
};
}
代码示例来源:origin: openzipkin/brave
public Filter afterAfter() {
return (request, response) -> {
Span span = tracer.currentSpan();
if (span == null) return;
((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close();
handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), null, span);
};
}
代码示例来源:origin: openzipkin/brave
public ExceptionHandler exception(ExceptionHandler delegate) {
return (exception, request, response) -> {
Span span = tracer.currentSpan();
if (span != null) {
((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close();
handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), exception, span);
}
delegate.handle(exception, request, response);
};
}
}
代码示例来源:origin: cinchapi/concourse
@Override
public void attribute(String attribute, Object value) {
delegate.attribute(attribute, value);
}
代码示例来源:origin: cinchapi/concourse
@Override
public Object attribute(String attribute) {
return delegate.attribute(attribute);
}
代码示例来源:origin: com.sparkjava/spark-core
@Override
public void attribute(String attribute, Object value) {
delegate.attribute(attribute, value);
}
代码示例来源:origin: com.sparkjava/spark-core
@Override
public <T> T attribute(String attribute) {
return delegate.attribute(attribute);
}
代码示例来源:origin: apache/james-project
@Override
public void handle(Request request, Response response) throws Exception {
if (request.attribute(MetricPreFilter.METRICS) instanceof TimeMetric) {
TimeMetric timeMetric = request.attribute(MetricPreFilter.METRICS);
timeMetric.stopAndPublish();
}
}
}
代码示例来源:origin: apache/james-project
@Override
public void handle(Request request, Response response) throws Exception {
Object attribute = request.attribute(MDCFilter.MDC_CLOSEABLE);
if (attribute instanceof Closeable) {
Closeable closeable = (Closeable) attribute;
closeable.close();
} else {
LOGGER.error("Invalid MDC closeable {} of class {}", attribute, attribute.getClass());
}
}
}
代码示例来源:origin: apache/james-project
@Override
public void handle(Request request, Response response) throws Exception {
request.attribute(METRICS, metricFactory.timer("webAdmin"));
}
}
代码示例来源:origin: apache/james-project
@Override
public void handle(Request request, Response response) throws Exception {
if (request.requestMethod() != OPTIONS) {
Optional<String> bearer = Optional.ofNullable(request.headers(AUTHORIZATION_HEADER_NAME))
.filter(value -> value.startsWith(AUTHORIZATION_HEADER_PREFIX))
.map(value -> value.substring(AUTHORIZATION_HEADER_PREFIX.length()));
checkHeaderPresent(bearer);
checkValidSignature(bearer);
checkIsAdmin(bearer);
String login = jwtTokenVerifier.extractLogin(bearer.get());
request.attribute(LOGIN, login);
}
}
代码示例来源:origin: io.zipkin.brave/brave-instrumentation-sparkjava
public Filter before() {
return (request, response) -> {
Span span = handler.handleReceive(extractor, request, request.raw());
request.attribute(Tracer.SpanInScope.class.getName(), tracer.withSpanInScope(span));
};
}
代码示例来源:origin: mgtechsoftware/smockin
@Override
public void register(final String path, final long heartBeatMillis, final boolean proxyPushIdOnConnect, final Request request, final Response response, final boolean logMockCalls) throws IOException {
logger.debug("register called");
final String clientId = GeneralUtils.generateUUID();
final String traceId = request.attribute(GeneralUtils.LOG_REQ_ID);
applyHeaders(response);
// Register client and build messages collection
clients.put(clientId, new ClientSseData(path, Thread.currentThread(), GeneralUtils.getCurrentDate()));
liveLoggingHandler.broadcast(LiveLoggingUtils.buildLiveLogOutboundDTO(traceId, response.status(), null, "SSE established (clientId: " + clientId + ")", false, false));
if (logMockCalls)
LiveLoggingUtils.MOCK_TRAFFIC_LOGGER.info(LiveLoggingUtils.buildLiveLogOutboundFileEntry(traceId, response.status(), null, "SSE established (clientId: " + clientId + ")", false, false));
initHeartBeat(clientId, heartBeatMillis, proxyPushIdOnConnect, traceId, response, logMockCalls);
}
代码示例来源:origin: io.zipkin.brave/brave-instrumentation-sparkjava
public Filter afterAfter() {
return (request, response) -> {
Span span = tracer.currentSpan();
if (span == null) return;
((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close();
handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), null, span);
};
}
代码示例来源:origin: cdelmas/microservices-comparison
public void filter(Request request, Response response) {
String token = readToken(request);
Try<User> user = accessTokenVerificationCommandFactory.createVerificationCommand(token).executeCommand();
user.peek(u ->
request.attribute("user", u))
.orElseRun(e -> halt(401, "{\"error\":\"" + e.getMessage() + "\"}"));
}
代码示例来源:origin: io.zipkin.brave/brave-instrumentation-sparkjava
public ExceptionHandler exception(ExceptionHandler delegate) {
return (exception, request, response) -> {
Span span = tracer.currentSpan();
if (span != null) {
((Tracer.SpanInScope) request.attribute(Tracer.SpanInScope.class.getName())).close();
handler.handleSend(ADAPTER.adaptResponse(request.raw(), response.raw()), exception, span);
}
delegate.handle(exception, request, response);
};
}
}
代码示例来源:origin: apache/james-project
@Override
public void handle(Request request, Response response) throws Exception {
Closeable mdcCloseable = MDCBuilder.create()
.addContext(MDCBuilder.IP, request.ip())
.addContext(MDCBuilder.HOST, request.host())
.addContext(VERB, request.requestMethod())
.addContext(MDCBuilder.PROTOCOL, "webadmin")
.addContext(MDCBuilder.ACTION, request.pathInfo())
.addContext(MDCBuilder.USER, request.attribute(AuthenticationFilter.LOGIN))
.build();
request.attribute(MDC_CLOSEABLE, mdcCloseable);
}
}
内容来源于网络,如有侵权,请联系作者删除!