Ether Framework
Unified API docs for Ether modules
Loading...
Searching...
No Matches
dev.rafex.ether.glowroot.jetty12.GlowrootJettyExtractors Class Reference

Factory of Jetty-specific HttpExchange extractor functions for use with GlowrootAuthUserMiddleware and GlowrootRequestIdMiddleware. More...

Collaboration diagram for dev.rafex.ether.glowroot.jetty12.GlowrootJettyExtractors:

Static Public Member Functions

static Function< HttpExchange, String > authUser ()
 Returns an extractor that reads the authenticated user from the JettyAuthHandler#REQ_ATTR_AUTH request attribute set by JettyAuthHandler after successful JWT verification.
static Function< HttpExchange, String > clientIp ()
 Returns an extractor for the client IP address, preferring X-Forwarded-For (set by reverse proxies / load-balancers) over the direct remote address.
static Function< HttpExchange, String > header (final String headerName)
 Returns an extractor that reads the value of a specific HTTP request header.
static Function< HttpExchange, String > xRequestId ()
 Returns an extractor for the X-Request-Id header, the de-facto standard for HTTP request correlation.

Detailed Description

Factory of Jetty-specific HttpExchange extractor functions for use with GlowrootAuthUserMiddleware and GlowrootRequestIdMiddleware.

All extractors safely return null when the exchange is not a JettyHttpExchange (e.g. during unit tests with a test double).

Usage:


// Set authenticated user from JWT auth context
middlewareRegistry.add(new GlowrootAuthUserMiddleware(GlowrootJettyExtractors.authUser()));

// Capture X-Request-Id header (generate if absent)
middlewareRegistry.add(new GlowrootRequestIdMiddleware(GlowrootJettyExtractors.xRequestId(), true));

// Capture any custom header
middlewareRegistry.add(new GlowrootRequestIdMiddleware(GlowrootJettyExtractors.header("X-Correlation-Id"), false));

Definition at line 60 of file GlowrootJettyExtractors.java.

Member Function Documentation

◆ authUser()

Function< HttpExchange, String > dev.rafex.ether.glowroot.jetty12.GlowrootJettyExtractors.authUser ( )
static

Returns an extractor that reads the authenticated user from the JettyAuthHandler#REQ_ATTR_AUTH request attribute set by JettyAuthHandler after successful JWT verification.

The raw context object is converted via toString(); implementors of dev.rafex.ether.http.jetty12.TokenVerifier should ensure the context object returns the user subject from toString().

Returns
extractor function that yields the authenticated user, or null

Definition at line 79 of file GlowrootJettyExtractors.java.

References dev.rafex.ether.http.jetty12.JettyAuthHandler.REQ_ATTR_AUTH.

◆ clientIp()

Function< HttpExchange, String > dev.rafex.ether.glowroot.jetty12.GlowrootJettyExtractors.clientIp ( )
static

Returns an extractor for the client IP address, preferring X-Forwarded-For (set by reverse proxies / load-balancers) over the direct remote address.

Returns
extractor function that yields the client IP address, or null

Definition at line 123 of file GlowrootJettyExtractors.java.

◆ header()

Function< HttpExchange, String > dev.rafex.ether.glowroot.jetty12.GlowrootJettyExtractors.header ( final String headerName)
static

Returns an extractor that reads the value of a specific HTTP request header.

Parameters
headerNamethe header name (case-insensitive per HTTP spec)
Returns
extractor function that yields the header value, or null if absent

Definition at line 96 of file GlowrootJettyExtractors.java.

Referenced by xRequestId().

Here is the caller graph for this function:

◆ xRequestId()

Function< HttpExchange, String > dev.rafex.ether.glowroot.jetty12.GlowrootJettyExtractors.xRequestId ( )
static

Returns an extractor for the X-Request-Id header, the de-facto standard for HTTP request correlation.

Returns
extractor function that yields the X-Request-Id header value, or null

Definition at line 112 of file GlowrootJettyExtractors.java.

References header().

Here is the call graph for this function:

The documentation for this class was generated from the following file: