本文整理汇总了Scala中play.core.SourceMapper类的典型用法代码示例。如果您正苦于以下问题:Scala SourceMapper类的具体用法?Scala SourceMapper怎么用?Scala SourceMapper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SourceMapper类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: ServerErrorHandler
//设置package包名称以及导入依赖的类
package utils.web
import org.slf4j.LoggerFactory
import play.api._
import play.api.http.DefaultHttpErrorHandler
import play.api.mvc.Results._
import play.api.mvc._
import play.api.routing.Router
import play.core.SourceMapper
import scala.concurrent.Future
class ServerErrorHandler(
env: play.api.Environment, config: Configuration,
sourceMapper: Option[SourceMapper], router: Option[Router]
) extends DefaultHttpErrorHandler(env, config, sourceMapper, router) {
private val log = LoggerFactory.getLogger(classOf[ServerErrorHandler])
override def onClientError(request: RequestHeader, statusCode: Int, message: String) = {
Future.successful(
Status(statusCode)("A client error occurred: " + message)
)
}
override def onServerError(request: RequestHeader, exception: Throwable) = {
log.error("Server error " + exception.getMessage + "for uri" + request.uri)
Future.successful(
InternalServerError("A server error occurred: " + exception.getMessage)
)
}
}
开发者ID:iriddhi,项目名称:mis,代码行数:33,代码来源:ServerErrorHandler.scala
示例2: environment
//设置package包名称以及导入依赖的类
package com.github.jacobono.modules
import play.api.{ Configuration, Environment }
import play.api.http.HttpErrorHandler
import play.api.routing.Router
import play.core.SourceMapper
import play.filters.csrf.{ CSRFConfig, CSRFFilter }
import play.filters.headers.SecurityHeadersFilter
import com.softwaremill.macwire._
import com.github.jacobono.utils._
trait UtilModule {
def environment: Environment
def configuration: Configuration
def sourceMapper: Option[SourceMapper]
def routerOption: Option[Router]
def csrfFilter: CSRFFilter
def csrfConfig: CSRFConfig
def securityHeadersFilter: SecurityHeadersFilter
lazy val filters = wire[Filters]
lazy val csrfHelper = wire[CSRFHelper]
lazy val errorHandler: HttpErrorHandler = wire[ErrorHandler]
}
开发者ID:jacobono,项目名称:silhouette-macwire,代码行数:28,代码来源:UtilModule.scala
示例3: run
//设置package包名称以及导入依赖的类
package controllers
import java.io.File
import loader.{AppApplicationLoader, AppComponents}
import mqtt.MqttConnector
import play.api.test.Helpers._
import play.api.ApplicationLoader.Context
import play.api._
import play.api.test.FakeRequest
import play.api.test.Helpers.{GET, contentAsString, route}
import play.core.{DefaultWebCommands, SourceMapper, WebCommands}
import play.filters.csrf.CSRF.Token
trait IntegrationTest {
var appComponents:BuiltInComponentsFromContext with WithoutMqttAppComponents = null
trait WithoutMqttAppComponents extends AppComponents {
override lazy val mqttConnector = new MqttConnector(null, null, actorSystem) {
override val reconnect = new Runnable {
override def run() = {}
}
}
}
class WithoutMqttApp extends AppApplicationLoader {
override def createApp(context: Context) = {
appComponents = new BuiltInComponentsFromContext(context) with WithoutMqttAppComponents
appComponents
}
}
implicit val app = new WithoutMqttApp()
.load(ApplicationLoader.Context(environment, sourceMapper, webCommands, configuration))
Play.start(app)
def getCsrfToken() = {
val request = FakeRequest(GET, "/data").withHeaders()
val page = route(app, request).get
val content = contentAsString(page)
val name = ("""<input type="hidden" id="csrf_token_name" value="([\w]+)">""".r).findFirstMatchIn(content).get.group(1)
val value = ("""<input type="hidden" id="csrf_token_value" value="([\w-]+)">""".r).findFirstMatchIn(content).get.group(1)
Token(name, value)
}
def sourceMapper: Option[SourceMapper] = None
def environment: Environment = Environment(new File("."), ClassLoader.getSystemClassLoader, Mode.Test)
def webCommands: WebCommands = new DefaultWebCommands
def configuration: Configuration = Configuration.load(Environment(new File("."), ClassLoader.getSystemClassLoader, Mode.Test))
}
开发者ID:vavravl1,项目名称:home_center,代码行数:53,代码来源:IntegrationTest.scala
示例4: ProdErrorHandler
//设置package包名称以及导入依赖的类
package services
import play.api.routing.Router
import play.api.{Configuration, Environment, Logger}
import play.api.http.DefaultHttpErrorHandler
import play.api.mvc._
import play.core.SourceMapper
import scala.concurrent._
class ProdErrorHandler(environment: Environment, configuration: Configuration,
sourceMapper: Option[SourceMapper] = None,
router: => Option[Router] = None)
extends DefaultHttpErrorHandler (
environment, configuration, sourceMapper, router) {
override protected def onNotFound(request: RequestHeader, message: String):
Future[Result] = {
implicit val req = request
Future.successful(Results.NotFound(views.html.errorPage()))
}
override def onServerError(request: RequestHeader, exception: Throwable):
Future[Result] = {
Logger.error("Exception occurred", exception)
implicit val req = request
Future.successful(Results.InternalServerError(views.html.errorPage()))
}
override protected def onBadRequest(request: RequestHeader, message: String):
Future[Result] = {
super.onBadRequest(request, message)
}
}
开发者ID:getArtemUsername,项目名称:play-and-events,代码行数:35,代码来源:ProdErrorHandler.scala
示例5: WebGatewayErrorHandler
//设置package包名称以及导入依赖的类
import javax.inject._
import javax.inject._
import org.slf4j.LoggerFactory
import play.api._
import play.api.http.DefaultHttpErrorHandler
import play.api.mvc.Results._
import play.api.mvc._
import play.api.routing.Router
import play.core.SourceMapper
import scala.concurrent.Future
class WebGatewayErrorHandler @Inject()(
env: play.api.Environment, config: Configuration,
sourceMapper: Option[SourceMapper], router: Option[Router]
) extends DefaultHttpErrorHandler(env, config, sourceMapper, router) {
private val log = LoggerFactory.getLogger(classOf[WebGatewayErrorHandler])
override def onClientError(request: RequestHeader, statusCode: Int, message: String) = {
Future.successful(
Status(statusCode)("A client error occurred: " + message)
)
}
override def onServerError(request: RequestHeader, exception: Throwable) = {
log.error("Server error " + exception.getMessage + "for uri" + request.uri)
Future.successful(
InternalServerError("A server error occurred: " + exception.getMessage)
)
}
}
开发者ID:francescopersico,项目名称:i,代码行数:37,代码来源:WebGatewayErrorHandler.scala
注:本文中的play.core.SourceMapper类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论