Package com.shri.restinpeace.interceptor
package com.shri.restinpeace.interceptor
-
ClassDescriptionPre-built interceptor that attaches a fresh correlation/request ID to every request - useful for tracing a call across service boundaries or correlating client-side logs with server-side logs.Pre-built interceptor that injects one or more headers into every request - the common "attach an auth token (or a batch of fixed headers) to every call" use case.Pre-built interceptor that logs a line before a request goes out and another when its response comes back, including the elapsed time.Pre-built interceptor that times every request and reports it, once its response comes back, to a
MetricsSink- the metrics counterpart ofLoggingInterceptor, following the exact same "bring your own sink" shape so RIP doesn't have to depend on Micrometer or any other metrics library to support one.Receives one completed call's metrics fromMetricsInterceptor- implement this to route them into Micrometer, a homegrown registry, or anything else, without RIP itself depending on a metrics library.ALoggingInterceptor-style pre-built interceptor that also logs the request and response bodies, masking a configured set of field names (case-insensitively) instead of printing them verbatim - so logging bodies is safe by default instead of a footgun.Per-call state passed to aRequestInterceptor'sbeforeRequest/afterResponse, sharing one instance across both so an interceptor can correlate state between them (e.g. a start timestamp for measuring request duration, viaRequestContext.setAttribute(java.lang.String, java.lang.Object)).How much extra diagnostic detailRequestContext.toCurlCommand(CurlVerbosity)askscurlitself to print, viacurl's own flags - RIP doesn't invent its own verbosity scheme, it just picks which standardcurlflag(s) to include.Global hook into every request/response made through RIP, registered viaRIP.addInterceptor(RequestInterceptor).A synthetic response aRequestInterceptor.shortCircuit(com.shri.restinpeace.interceptor.RequestContext)can hand back to skip the network call entirely - the request is never sent, and this response is decoded exactly as if it had come back from a real one (including throwingRestInPeaceHttpExceptionfor a non-2xx status, and being visible to every registered interceptor's ownafterResponse).