@Override
  public void handleRequest(HttpServerExchange httpServerExchange) {
    if (!httpServerExchange.getRequestMethod().equals(HttpString.tryFromString("GET"))) {
      httpServerExchange.setStatusCode(HTTP_METHOD_NOT_ALLOWED);
      httpServerExchange.getResponseSender().send("");
    } else {
      httpServerExchange.setStatusCode(HTTP_OK);
      httpServerExchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/plain");

      var metricsContents = registry.scrape();
      httpServerExchange.getResponseSender().send(metricsContents);
    }
  }
@Test
  void get() {
    // when
    var httpServerExchange = mock(HttpServerExchange.class);
    var headers = mock(HeaderMap.class);
    var sender = mock(Sender.class);

    when(httpServerExchange.getResponseHeaders()).thenReturn(headers);
    when(httpServerExchange.getResponseSender()).thenReturn(sender);
    when(httpServerExchange.getRequestMethod()).thenReturn(HttpString.tryFromString("GET"));

    // given
    var prometheusMeterRegistry = new PrometheusMeterRegistry(PrometheusConfig.DEFAULT);

    var counter = prometheusMeterRegistry.counter("test.counter");

    counter.increment(2.0);

    var sut = new MetricsEndpoint(prometheusMeterRegistry);

    // when
    sut.handleRequest(httpServerExchange);

    // then
    verify(sender).send(responseCaptor.capture());
    assertTrue(responseCaptor.getValue().contains("test_counter_total 2.0"));
  }