Update documentation on Actuator hypermedia support

Spring Boot Actuator hypermedia support has been disabled by default via
c7c685f, but its documentation wasn't updated.

This commit updates the documentation related to the change.

See gh-7215
This commit is contained in:
Johnny Lim 2016-10-24 22:58:27 +09:00 committed by Stephane Nicoll
parent 7f8849c62b
commit 1546cd4072
5 changed files with 17 additions and 4 deletions

View File

@ -44,6 +44,11 @@
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@ -82,6 +87,10 @@
<groupId>org.springframework.hateoas</groupId> <groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId> <artifactId>spring-hateoas</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.plugin</groupId>
<artifactId>spring-plugin-core</artifactId>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.restdocs</groupId> <groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-mockmvc</artifactId> <artifactId>spring-restdocs-mockmvc</artifactId>

View File

@ -58,7 +58,7 @@ HAL browser is not active).
== Hypermedia Support == Hypermedia Support
If https://projects.spring.io/spring-hateoas[Spring HATEOAS] is enabled (i.e. if it is If https://projects.spring.io/spring-hateoas[Spring HATEOAS] is enabled (i.e. if it is
on the classpath by default) then the Actuator endpoint responses are enhanced with on the classpath by default) and `endpoints.hypermedia.enabled` is set to `true` then the Actuator endpoint responses are enhanced with
hypermedia in the form of "links". The default media type for responses is hypermedia in the form of "links". The default media type for responses is
http://stateless.co/hal_specification.html[HAL], resulting in each resource having an http://stateless.co/hal_specification.html[HAL], resulting in each resource having an
extra property called "_links". You can change the media type to another one supported by extra property called "_links". You can change the media type to another one supported by

View File

@ -33,12 +33,13 @@ import org.springframework.test.web.servlet.MockMvc;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document; import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(classes = SpringBootHypermediaApplication.class, loader = SpringBootContextLoader.class) @ContextConfiguration(classes = SpringBootHypermediaApplication.class, loader = SpringBootContextLoader.class)
@WebAppConfiguration @WebAppConfiguration
@TestPropertySource(properties = "spring.jackson.serialization.indent_output=true") @TestPropertySource(properties = { "spring.jackson.serialization.indent_output=true", "endpoints.hypermedia.enabled=true" })
@DirtiesContext @DirtiesContext
@AutoConfigureMockMvc @AutoConfigureMockMvc
@AutoConfigureRestDocs("target/generated-snippets") @AutoConfigureRestDocs("target/generated-snippets")
@ -56,7 +57,9 @@ public class HypermediaEndpointDocumentation {
@Test @Test
public void metrics() throws Exception { public void metrics() throws Exception {
this.mockMvc.perform(get("/metrics").accept(MediaType.APPLICATION_JSON)) this.mockMvc.perform(get("/metrics").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andDo(document("metrics/hypermedia")); .andExpect(status().isOk())
.andExpect(jsonPath("$._links.self.href").value("http://localhost:8080/metrics"))
.andDo(document("metrics/hypermedia"));
} }
@Test @Test

View File

@ -930,6 +930,7 @@ content into your application; rather pick only the properties that you need.
# ENDPOINTS ({sc-spring-boot-actuator}/endpoint/AbstractEndpoint.{sc-ext}[AbstractEndpoint] subclasses) # ENDPOINTS ({sc-spring-boot-actuator}/endpoint/AbstractEndpoint.{sc-ext}[AbstractEndpoint] subclasses)
endpoints.enabled=true # Enable endpoints. endpoints.enabled=true # Enable endpoints.
endpoints.sensitive= # Default endpoint sensitive setting. endpoints.sensitive= # Default endpoint sensitive setting.
endpoints.hypermedia.enabled=false # Enable hypermedia support for endpoints.
endpoints.actuator.enabled=true # Enable the endpoint. endpoints.actuator.enabled=true # Enable the endpoint.
endpoints.actuator.path= # Endpoint URL path. endpoints.actuator.path= # Endpoint URL path.
endpoints.actuator.sensitive=false # Enable security on the endpoint. endpoints.actuator.sensitive=false # Enable security on the endpoint.

View File

@ -205,7 +205,7 @@ For example, to mark _all_ endpoints as sensitive except `info`:
=== Hypermedia for actuator MVC endpoints === Hypermedia for actuator MVC endpoints
If http://projects.spring.io/spring-hateoas[Spring HATEOAS] is on the classpath (e.g. If http://projects.spring.io/spring-hateoas[Spring HATEOAS] is on the classpath (e.g.
through the `spring-boot-starter-hateoas` or if you are using through the `spring-boot-starter-hateoas` or if you are using
http://projects.spring.io/spring-data-rest[Spring Data REST]) then the HTTP endpoints http://projects.spring.io/spring-data-rest[Spring Data REST]) and `endpoints.hypermedia.enabled` is set to `true` then the HTTP endpoints
from the Actuator are enhanced with hypermedia links, and a "`discovery page`" is added from the Actuator are enhanced with hypermedia links, and a "`discovery page`" is added
with links to all the endpoints. The "`discovery page`" is available on `/actuator` by with links to all the endpoints. The "`discovery page`" is available on `/actuator` by
default. It is implemented as an endpoint, allowing properties to be used to configure default. It is implemented as an endpoint, allowing properties to be used to configure