2

I'm trying to override health endpoint. I need to make it return something else then 'OK'. As described in docs, I should use Lifecycle.Warmup trait. Neither

HttpMuxer.addHandler(Route("/health", new ReplyHandler("not OK\n"))) 

nor overriding method doesn't helped yet.

This code below, doesn't help either.

HttpMuxer.addHandler(
      Route(
        pattern = "/health",
        handler = new ReplyHandler("not OK\n"),
        index = Some(RouteIndex(
          alias = "Health",
          group = group))))

What should I do to change this message?

UPD: One more approach which should work but it doesn't

premain {
    addAdminRoute(
      AdminHttpServer
        .Route("/health1",
          handler = service,
          "Service Health",
          Some("Misc"),
          false, Method.Get)
    )
  }
  val service = new Service[Request, Response] {
    def apply(request: Request) = {
      val response = Response(request.version, Status.Ok)
      response.contentString = "test" + "\n"
      com.twitter.util.Future.value(response)
    }
  }

I debug, I see it's added to Muxer, I see it appears in logs as well. Have no idea why it doesn't work

Logs

green-creeper
  • 316
  • 3
  • 15

2 Answers2

0

That looks like it should work. You should double check that the url you're hitting is $ADMIN_HOST:$ADMIN_PORT/health and not $ADMIN_HOST:$ADMIN_PORT/admin/health.

nnythm
  • 3,280
  • 4
  • 26
  • 36
0

Sounds a bit fantastic, but if I place this code before main, instead of premain - it works.

HttpMuxer.addHandler(
    Route(
      pattern = "/health",
      handler = new ReplyHandler("not OK\n"),
      index = Some(RouteIndex(alias = "Health", group = group))
    )
  )
green-creeper
  • 316
  • 3
  • 15