diff --git a/otoroshi/app/next/controllers/plugins.scala b/otoroshi/app/next/controllers/plugins.scala index a8004b0a5..0b8e253b2 100644 --- a/otoroshi/app/next/controllers/plugins.scala +++ b/otoroshi/app/next/controllers/plugins.scala @@ -17,7 +17,12 @@ class NgPluginsController( implicit val ec = env.otoroshiExecutionContext def categories() = ApiAction { - Ok(JsArray(NgPluginCategory.all.map(_.json))) + val pluginsCategories = env.scriptManager.ngNames.distinct + .filterNot(_.contains(".NgMerged")) + .flatMap(name => env.scriptManager.getAnyScript[NgNamedPlugin](s"cp:$name").toOption.map(o => (name, o))) + .flatMap(_._2.categories) + val categories = (NgPluginCategory.all ++ pluginsCategories).distinct.sortWith((a, b) => a.name.compareToIgnoreCase(b.name) < 0).map(_.json) + Ok(JsArray(categories)) } def steps() = ApiAction { diff --git a/otoroshi/app/next/plugins/api.scala b/otoroshi/app/next/plugins/api.scala index bdb768ae6..71cf25e2f 100644 --- a/otoroshi/app/next/plugins/api.scala +++ b/otoroshi/app/next/plugins/api.scala @@ -245,6 +245,7 @@ object NgPluginCategory { case object Classic extends NgPluginCategory { def name: String = "Classic" } case object ServiceDiscovery extends NgPluginCategory { def name: String = "ServiceDiscovery" } case object Websocket extends NgPluginCategory { def name: String = "Websocket" } + case class Custom(name: String) extends NgPluginCategory val all = Seq( Classic,