package com.example.demoendpoint; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import org.springframework.boot.actuate.endpoint.annotation.Endpoint; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.annotation.Selector; import org.springframework.stereotype.Component; import org.springframework.util.Assert; @Component @Endpoint(id="my-params") public class MyCustomEndpoint { @ReadOperation public Map> showParameters() { Map> params = new HashMap<>(); params.put("cat1", Arrays.asList(new Parameter("url", "toto"), new Parameter("user", "titi"))); params.put("cat2", Arrays.asList(new Parameter("key.1", "secret"), new Parameter("key.2", "sE3reT"))); params.put("cat3", Arrays.asList(new Parameter("other1", "foo"), new Parameter("other2", "bar"))); return params; } @ReadOperation public List showParametersByCategory(@Selector String category) { Assert.notNull(category, "category must not be null"); switch (category) { case "cat1" : return Arrays.asList(new Parameter("url", "toto"), new Parameter("user", "titi")); case "cat2" : return Arrays.asList(new Parameter("key.1", "secret"), new Parameter("key.2", "sE3reT")); case "cat3" : return Arrays.asList(new Parameter("other1", "foo"), new Parameter("other2", "bar")); default : return Collections.emptyList(); } } private static class Parameter { private final String name; private final String value; Parameter(String name, String value) { this.name = name; this.value = value; } public String getName() { return name; } public String getValue() { return value; } } }