Rename headers to header.

This commit is contained in:
Stephan Schnabel 2021-12-13 14:06:59 +01:00
parent 0edd98d7a4
commit 7403b04efd
Signed by: stephan.schnabel
GPG key ID: F74FE2422AA07290
5 changed files with 43 additions and 43 deletions

View file

@ -26,18 +26,18 @@ import lombok.extern.slf4j.Slf4j;
* @author Stephan Schnabel
*/
@Refreshable
@Requires(property = HttpHeadersMdcFilter.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
@Requires(property = HttpHeadersMdcFilter.PREFIX + ".names")
@Filter("${" + HttpHeadersMdcFilter.PREFIX + ".path:/**}")
@Requires(property = HeaderMdcFilter.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
@Requires(property = HeaderMdcFilter.PREFIX + ".names")
@Filter("${" + HeaderMdcFilter.PREFIX + ".path:/**}")
@Slf4j
public class HttpHeadersMdcFilter extends AbstractMdcFilter {
public class HeaderMdcFilter extends AbstractMdcFilter {
public static final String PREFIX = "logger.http.headers";
public static final String PREFIX = "logger.http.header";
public static final int DEFAULT_ORDER = ServerFilterPhase.FIRST.before();
private final Set<String> headers;
public HttpHeadersMdcFilter(
public HeaderMdcFilter(
@Value("${" + PREFIX + ".names}") List<String> headers,
@Value("${" + PREFIX + ".prefix}") Optional<String> prefix,
@Value("${" + PREFIX + ".order}") Optional<Integer> order) {

View file

@ -11,12 +11,12 @@ import io.kokuwa.micronaut.logging.http.AbstractFilterTest;
import io.micronaut.context.annotation.Property;
/**
* Test for {@link HttpHeadersMdcFilter}.
* Test for {@link HeaderMdcFilter}.
*
* @author Stephan Schnabel
*/
@DisplayName("http: mdc from headers")
public class HttpHeadersMdcFilterTest extends AbstractFilterTest {
public class HeaderMdcFilterTest extends AbstractFilterTest {
@DisplayName("noop: empty configuration")
@Test
@ -26,30 +26,30 @@ public class HttpHeadersMdcFilterTest extends AbstractFilterTest {
@DisplayName("noop: disabled")
@Test
@Property(name = "logger.http.headers.enabled", value = "false")
@Property(name = "logger.http.headers.names", value = "foo")
@Property(name = "logger.http.header.enabled", value = "false")
@Property(name = "logger.http.header.names", value = "foo")
void noopDisabled() {
assertContext(Map.of(), Map.of("foo", "bar"));
}
@DisplayName("mdc: mismatch")
@Test
@Property(name = "logger.http.headers.names", value = "foo")
@Property(name = "logger.http.header.names", value = "foo")
void mdcMismatch() {
assertContext(Map.of(), Map.of("nope", "bar"));
}
@DisplayName("mdc: match without prefix")
@Test
@Property(name = "logger.http.headers.names", value = "foo")
@Property(name = "logger.http.header.names", value = "foo")
void mdcMatchWithoutPrefix() {
assertContext(Map.of("foo", "bar"), Map.of("foo", "bar", "nope", "bar"));
}
@DisplayName("mdc: match with prefix")
@Test
@Property(name = "logger.http.headers.names", value = "foo")
@Property(name = "logger.http.headers.prefix", value = "header.")
@Property(name = "logger.http.header.names", value = "foo")
@Property(name = "logger.http.header.prefix", value = "header.")
void mdcMatchWithPrefix() {
assertContext(Map.of("header.foo", "bar"), Map.of("foo", "bar", "nope", "bar"));
}