Skip to content

Commit

Permalink
Add custom plugin categories
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuancelin committed Feb 29, 2024
1 parent 0af3bee commit 7b94684
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion otoroshi/app/next/controllers/plugins.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions otoroshi/app/next/plugins/api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7b94684

Please sign in to comment.