diff --git a/otoroshi/app/api/api.scala b/otoroshi/app/api/api.scala index c8b417a9e1..cf59e4a377 100644 --- a/otoroshi/app/api/api.scala +++ b/otoroshi/app/api/api.scala @@ -294,18 +294,8 @@ case class GenericResourceAccessApiWithState[T <: EntityLocationSupport]( override def update(values: Seq[T]): Unit = stateUpdate(values) } -class GenericApiController(ApiAction: ApiAction, cc: ControllerComponents)(implicit env: Env) - extends AbstractController(cc) { - - private val sourceBodyParser = BodyParser("GenericApiController BodyParser") { _ => - Accumulator.source[ByteString].map(Right.apply)(env.otoroshiExecutionContext) - } - - private implicit val ec = env.otoroshiExecutionContext - - private implicit val mat = env.otoroshiMaterializer - - private lazy val resources = Seq( +class OtoroshiResources(env: Env) { + lazy val resources = Seq( /////// Resource( "Route", @@ -578,6 +568,18 @@ class GenericApiController(ApiAction: ApiAction, cc: ControllerComponents)(impli ) ) ) ++ env.adminExtensions.resources() +} + +class GenericApiController(ApiAction: ApiAction, cc: ControllerComponents)(implicit env: Env) + extends AbstractController(cc) { + + private val sourceBodyParser = BodyParser("GenericApiController BodyParser") { _ => + Accumulator.source[ByteString].map(Right.apply)(env.otoroshiExecutionContext) + } + + private implicit val ec = env.otoroshiExecutionContext + + private implicit val mat = env.otoroshiMaterializer private def filterPrefix: Option[String] = "filter.".some @@ -854,7 +856,7 @@ class GenericApiController(ApiAction: ApiAction, cc: ControllerComponents)(impli request: RequestHeader, bulk: Boolean = false )(f: Resource => Future[Result]): Future[Result] = { - resources + env.allResources.resources .filter(_.version.served) .find(r => (group == "any" || r.group == group) && (version == "any" || r.version.name == version) && r.pluralName == entity diff --git a/otoroshi/app/env/Env.scala b/otoroshi/app/env/Env.scala index 568abd8b70..fc7391cc7d 100644 --- a/otoroshi/app/env/Env.scala +++ b/otoroshi/app/env/Env.scala @@ -973,6 +973,8 @@ class Env( val servers = TcpService.runServers(this) + lazy val allResources = new otoroshi.api.OtoroshiResources(this) + lazy val adminExtensionsConfig = AdminExtensionConfig( enabled = configuration.getOptionalWithFileSupport[Boolean]("otoroshi.admin-extensions.enabled").getOrElse(true) ) diff --git a/otoroshi/app/storage/storage.scala b/otoroshi/app/storage/storage.scala index 32781bca1f..8e2be050e7 100644 --- a/otoroshi/app/storage/storage.scala +++ b/otoroshi/app/storage/storage.scala @@ -259,7 +259,7 @@ trait OptimizedRedisLike { case _ if key.startsWith(ds.backendsDataStore.key("")) => "backend".some case _ if key.startsWith(ds.wasmPluginsDataStore.key("")) => "wasm-plugin".some case _ => { - env.adminExtensions.resources() + env.allResources.resources .map { res => (key.startsWith(res.access.key("")), res.singularName) }