@Override @GetMapping(produces = TextFormat.CONTENT_TYPE_004) @HypermediaDisabled @ResponseBody public ResponseEntity<String> invoke() { PrometheusMetrics prometheusMetrics = (PrometheusMetrics) super.invoke(); Writer writer = new StringWriter(); try { TextFormat.write004(writer, Collections.enumeration(prometheusMetrics.getMetricFamilySamples())); } catch (IOException e) { log.error("metric write error", e); } HttpStatus status = prometheusMetrics.isUp() ? HttpStatus.OK : HttpStatus.INTERNAL_SERVER_ERROR; String body = writer.toString(); ResponseEntity<String> response = new ResponseEntity<>(body, status); return response; }
@GetMapping(value = "/{name:.*}", produces = {ActuatorMediaTypes.APPLICATION_ACTUATOR_V1_JSON_VALUE, MediaType.APPLICATION_JSON_VALUE}) @ResponseBody @HypermediaDisabled public String handle(@PathVariable String name) { String temp = name; if (name.contains(".")) { temp = name.substring(0, name.indexOf(".")); } name = "/" + temp + ".json"; return statService.service(name); }
@RequestMapping(value = "/{eventType:.*}", method = RequestMethod.POST) @ResponseBody @HypermediaDisabled public ResponseEntity<?> createSnapshot(@PathVariable String eventType, @RequestBody(required = false) String filter) { if (!this.delegate.isEnabled()) { // Shouldn't happen - MVC endpoint shouldn't be registered when delegate's // disabled return getDisabledResponse(); } delegate.invoke(eventType, filter); return ResponseEntity.ok().build(); }
private boolean isHypermediaDisabled(MethodParameter returnType) { return AnnotationUtils.findAnnotation(returnType.getMethod(), HypermediaDisabled.class) != null || AnnotationUtils.findAnnotation( returnType.getMethod().getDeclaringClass(), HypermediaDisabled.class) != null; }
@RequestMapping(method = RequestMethod.GET, produces = TextFormat.CONTENT_TYPE_004) @ResponseBody @HypermediaDisabled protected Object invoke() { if (!getDelegate().isEnabled()) { return new ResponseEntity<>( Collections.singletonMap("message", "This endpoint is disabled"), HttpStatus.NOT_FOUND); } return super.invoke(); }