private[this] def addLegacyController()

in thrift/src/main/scala/com/twitter/finatra/thrift/routing/routers.scala [335:364]


  private[this] def addLegacyController(
    controller: Controller,
    conf: Controller.LegacyConfig
  ): ThriftService = {
    if (conf.methods.isEmpty) {
      logger.error(
        s"${controller.getClass.getName} contains no visible methods. " +
          s"For more details see: ${ThriftRouter.url}"
      )
    } else {
      routes = conf.methods.map { methodService =>
        val method = methodService.method
        thriftMethodRegistrar.register(controller.getClass, method, Filter.TypeAgnostic.Identity)
        methodService.setStack(filterStack)
        // Convert to a ScroogeServiceImpl for issuing warmup requests
        val castedService = methodService.asInstanceOf[Service[method.Args, method.SuccessType]]
        val reqRepService = Service.mk[Request[method.Args], Response[method.SuccessType]] { req =>
          castedService(req.args).map(Response[method.SuccessType])
        }
        method -> reqRepService.asInstanceOf[ScroogeServiceImpl]
      }.toMap

      logger.info(
        "Adding methods\n" + conf.methods
          .map(method => s"${controller.getClass.getSimpleName}.${method.name}")
          .mkString("\n")
      )
    }
    controller.asInstanceOf[ToThriftService].toThriftService
  }