mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Mark log file endpoint as producing text/plain
Closes gh-16188
This commit is contained in:
parent
7153525ee2
commit
f574213cc8
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2017 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -55,7 +55,7 @@ public class LogFileWebEndpoint {
|
|||||||
this(environment, null);
|
this(environment, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ReadOperation
|
@ReadOperation(produces = "text/plain")
|
||||||
public Resource logFile() {
|
public Resource logFile() {
|
||||||
Resource logFileResource = getLogFileResource();
|
Resource logFileResource = getLogFileResource();
|
||||||
if (logFileResource == null || !logFileResource.isReadable()) {
|
if (logFileResource == null || !logFileResource.isReadable()) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2017 the original author or authors.
|
* Copyright 2012-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -31,6 +31,7 @@ import org.springframework.context.ConfigurableApplicationContext;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||||
import org.springframework.util.FileCopyUtils;
|
import org.springframework.util.FileCopyUtils;
|
||||||
|
|
||||||
@ -71,6 +72,14 @@ public class LogFileWebEndpointWebIntegrationTests {
|
|||||||
.expectBody(String.class).isEqualTo("--TEST--");
|
.expectBody(String.class).isEqualTo("--TEST--");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getRequestThatAcceptsTextPlainProducesResponseWithLogFile() {
|
||||||
|
TestPropertyValues.of("logging.file:" + this.logFile.getAbsolutePath())
|
||||||
|
.applyTo(context);
|
||||||
|
client.get().uri("/actuator/logfile").accept(MediaType.TEXT_PLAIN).exchange()
|
||||||
|
.expectStatus().isOk().expectBody(String.class).isEqualTo("--TEST--");
|
||||||
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
static class TestConfiguration {
|
static class TestConfiguration {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user