本文整理汇总了Scala中play.api.libs.concurrent.Execution.Implicits.defaultContext类的典型用法代码示例。如果您正苦于以下问题:Scala defaultContext类的具体用法?Scala defaultContext怎么用?Scala defaultContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了defaultContext类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: ErrorHandler
//设置package包名称以及导入依赖的类
import javax.inject.{Inject, Provider, Singleton}
import play.api.http.DefaultHttpErrorHandler
import play.api.i18n.{I18nSupport, Messages, MessagesApi}
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.mvc.Results._
import play.api.mvc.{RequestHeader, Result}
import play.api.routing.Router
import play.api.{Configuration, Environment, OptionalSourceMapper, UsefulException}
import views.ErrorView
import scala.concurrent.Future
import play.api.libs.concurrent.Execution.Implicits.defaultContext
@Singleton
class ErrorHandler @Inject()(env: Environment,
config: Configuration,
sourceMapper: OptionalSourceMapper,
router: Provider[Router],
val messagesApi: MessagesApi
) extends DefaultHttpErrorHandler(env, config, sourceMapper, router) with I18nSupport {
override def onProdServerError(request: RequestHeader, exception: UsefulException): Future[Result] = {
implicit val requestHeader = request
Future.successful(InternalServerError(ErrorView(Messages("error.server"), exception.getMessage, "server_error")))
}
override def onForbidden(request: RequestHeader, message: String): Future[Result] = {
implicit val requestHeader = request
Future.successful(Forbidden(ErrorView(Messages("error.forbidden_access"), message, "unauthorized_error")))
}
}