001package io.prometheus.client.spring.boot; 002 003import io.prometheus.client.exporter.common.TextFormat; 004import org.springframework.beans.factory.annotation.Autowired; 005import org.springframework.boot.actuate.endpoint.mvc.AbstractEndpointMvcAdapter; 006import org.springframework.web.bind.annotation.RequestMapping; 007import org.springframework.web.bind.annotation.RequestMethod; 008 009public class PrometheusMVCEndpoint extends AbstractEndpointMvcAdapter<PrometheusEndpoint> { 010 011 @Autowired 012 public PrometheusMVCEndpoint(PrometheusEndpoint delegate) { 013 super(delegate); 014 } 015 016 @RequestMapping(value = "", method = RequestMethod.GET, produces = TextFormat.CONTENT_TYPE_004) 017 public Object invoke() { 018 if (!getDelegate().isEnabled()) { 019 // Shouldn't happen because the request mapping should not be registered 020 return getDisabledResponse(); 021 } else { 022 return getDelegate().invoke(); 023 } 024 } 025}