本文整理汇总了Scala中play.api.mvc.BodyParser类的典型用法代码示例。如果您正苦于以下问题:Scala BodyParser类的具体用法?Scala BodyParser怎么用?Scala BodyParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BodyParser类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: Utility
//设置package包名称以及导入依赖的类
package controllers
import play.api.Play
import play.api.mvc.{BodyParser, MultipartFormData, RequestHeader}
import play.core.parsers.Multipart
object Utility {
import play.api.mvc.BodyParsers.parse._
def multipartFormData[A](filePartHandler: RequestHeader => Multipart.FilePartHandler[A], maxLength: Long = DefaultMaxDiskLength): BodyParser[MultipartFormData[A]] = {
BodyParser("multipartFormData") { request =>
val app = play.api.Play.current // throw exception
implicit val mat = app.materializer
val bodyAccumulator = Multipart.multipartParser(DefaultMaxTextLength, filePartHandler(request)).apply(request)
// TODO enforceMaxLength(request, maxLength, bodyAccumulator) or maybe not
bodyAccumulator
}
}
}
开发者ID:ejosiah,项目名称:crypto-utility,代码行数:23,代码来源:Utility.scala
示例2: Auth
//设置package包名称以及导入依赖的类
package utils.auth.deadbolt
import javax.inject.{Inject, Singleton}
import be.objectify.deadbolt.scala.DeadboltActions
import com.mohiva.play.silhouette.api.Silhouette
import models.Roles
import play.api.mvc.{BodyParser, BodyParsers, Result, Results}
import utils.auth.DefaultEnv
import scala.concurrent.Future
@Singleton
class Auth @Inject()(deadboltActions: DeadboltActions, silhouette: Silhouette[DefaultEnv])
extends Results with BodyParsers {
def SubjectPresent[B](parser: BodyParser[B] = parse.anyContent)(block: SecureRequest[B] => Future[Result]) =
silhouette.SecuredAction.async(parser) { implicit req =>
deadboltActions.SubjectPresent()(parser)(block.compose(_ => new SecureRequest(req)))(req)
}
def Restrict[B](parser: BodyParser[B] = parse.anyContent)(role: Roles.Role)(block: SecureRequest[B] => Future[Result]) =
silhouette.SecuredAction.async(parser) { implicit request =>
deadboltActions.Restrict(role.group)(parser)(block.compose(_ => new SecureRequest(request)))(request)
}
}
开发者ID:dexmo007,项目名称:play-sil-seed-exp,代码行数:29,代码来源:Auth.scala
注:本文中的play.api.mvc.BodyParser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论