@Override public void attribute(String attribute, Object value) { delegate.attribute(attribute, value); }
@Override public <T> T attribute(String attribute) { return delegate.attribute(attribute); }
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()); }
public Filter before() { return (request, response) -> { Span span = handler.handleReceive(extractor, request, request.raw()); request.attribute(Tracer.SpanInScope.class.getName(), tracer.withSpanInScope(span)); }; }
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); }; }
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); }; } }
@Override public void attribute(String attribute, Object value) { delegate.attribute(attribute, value); }
@Override public Object attribute(String attribute) { return delegate.attribute(attribute); }
@Override public void attribute(String attribute, Object value) { delegate.attribute(attribute, value); }
@Override public <T> T attribute(String attribute) { return delegate.attribute(attribute); }
@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()); } } }
@Override public void handle(Request request, Response response) throws Exception { request.attribute(METRICS, metricFactory.timer("webAdmin")); } }
@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); } }
public Filter before() { return (request, response) -> { Span span = handler.handleReceive(extractor, request, request.raw()); request.attribute(Tracer.SpanInScope.class.getName(), tracer.withSpanInScope(span)); }; }
@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); }
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); }; }
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() + "\"}")); }
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); }; } }
@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); } }