def routes: Route = prepareCombinedRoutes()

in management/src/main/scala/org/apache/pekko/management/scaladsl/PekkoManagement.scala [102:147]


  def routes: Route = prepareCombinedRoutes(providerSettings)

  /**
   * Amend the [[ManagementRouteProviderSettings]] and get the routes for the HTTP management endpoint.
   *
   * Use this when adding authentication and HTTPS.
   *
   * This method can be used to embed the Pekko management routes in an existing Pekko HTTP server.
   *
   * @throws java.lang.IllegalArgumentException if routes not configured for pekko management
   */
  def routes(transformSettings: ManagementRouteProviderSettings => ManagementRouteProviderSettings): Route =
    prepareCombinedRoutes(transformSettings(providerSettings))

  /**
   * Start a Pekko HTTP server to serve the HTTP management endpoint.
   */
  def start(): Future[Uri] =
    start(identity)

  /**
   * Amend the [[ManagementRouteProviderSettings]] and start a Pekko HTTP server to serve
   * the HTTP management endpoint.
   *
   * Use this when adding authentication and HTTPS.
   */
  def start(transformSettings: ManagementRouteProviderSettings => ManagementRouteProviderSettings): Future[Uri] = {
    val serverBindingPromise = Promise[Http.ServerBinding]()
    val effectiveProviderSettings = transformSettings(providerSettings)
    if (bindingFuture.compareAndSet(null, (effectiveProviderSettings, serverBindingPromise.future))) {
      try {
        start(effectiveProviderSettings, serverBindingPromise)
      } catch {
        case NonFatal(ex) =>
          log.warning(ex.getMessage)
          Future.failed(new IllegalArgumentException("Failed to start Pekko Management HTTP endpoint.", ex))
      }
    } else {
      val (configForExistingBinding, _) = bindingFuture.get()
      if (configForExistingBinding == effectiveProviderSettings)
        selfUriPromise.future
      else
        Future.failed(
          new IllegalStateException("Management extension already started with different configuration parameters"))
    }
  }