controllers.adminapi.CanaryController.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otoroshi_2.12 Show documentation
Show all versions of otoroshi_2.12 Show documentation
Lightweight api management on top of a modern http reverse proxy
The newest version!
package otoroshi.controllers.adminapi
import otoroshi.actions.ApiAction
import otoroshi.env.Env
import play.api.Logger
import play.api.libs.json.Json
import play.api.mvc.{AbstractController, ControllerComponents}
class CanaryController(ApiAction: ApiAction, cc: ControllerComponents)(implicit env: Env)
extends AbstractController(cc) {
implicit lazy val ec = env.otoroshiExecutionContext
implicit lazy val mat = env.otoroshiMaterializer
lazy val logger = Logger("otoroshi-canary-api")
def serviceCanaryMembers(serviceId: String) =
ApiAction.async { ctx =>
ctx.canReadService(serviceId) {
env.datastores.canaryDataStore.canaryCampaign(serviceId).map { campaign =>
Ok(
Json.obj(
"canaryUsers" -> campaign.canaryUsers,
"standardUsers" -> campaign.standardUsers
)
)
}
}
}
def resetServiceCanaryMembers(serviceId: String) =
ApiAction.async { ctx =>
ctx.canWriteService(serviceId) {
env.datastores.canaryDataStore.destroyCanarySession(serviceId).map { done =>
Ok(Json.obj("done" -> done))
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy