本文整理汇总了Scala中uk.gov.hmrc.time.DateTimeUtils类的典型用法代码示例。如果您正苦于以下问题:Scala DateTimeUtils类的具体用法?Scala DateTimeUtils怎么用?Scala DateTimeUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateTimeUtils类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: TagNames
//设置package包名称以及导入依赖的类
package uk.gov.hmrc.audit.model
import java.util.UUID
import org.joda.time.DateTime
import uk.gov.hmrc.http.{HeaderCarrier, HeaderNames}
import uk.gov.hmrc.play.audit.model.DataCall
import uk.gov.hmrc.time.DateTimeUtils
object TagNames {
val path = "path"
val clientIP = "clientIP"
val clientPort = "clientPort"
val transactionName = "transactionName"
val requestID: String = HeaderNames.xRequestId
val sessionID: String = HeaderNames.xSessionId
val authorisation: String = HeaderNames.authorisation
val excludedFromDetail = Seq(path, clientIP, clientPort, transactionName, requestID, sessionID, authorisation)
}
object LegacyDetailNames {
val method = "method"
val statusCode = "method"
val requestBody = "requestBody"
val responseMessage = "responseMessage"
val akamaiReputation = "Akamai-Reputation"
}
@deprecated("Use class uk.gov.hmrc.audit.model.AuditEvent")
object DataEvent {
def apply(auditSource: String,
auditType: String,
eventId: String = UUID.randomUUID().toString,
tags: Map[String, String] = Map.empty,
detail: Map[String, String] = Map.empty,
generatedAt: DateTime = DateTimeUtils.now)(implicit hc: HeaderCarrier = HeaderCarrier()): AuditEvent = {
val sessionId = if (tags.contains(TagNames.sessionID)) Some(tags(TagNames.sessionID)) else None
val authorisationToken = if (tags.contains(TagNames.authorisation)) Some(tags(TagNames.authorisation)) else None
val requestId = Some(tags.getOrElse(TagNames.requestID, ""))
val clientIP = if (tags.contains(TagNames.clientIP)) Some(tags(TagNames.clientIP)) else None
val clientPort = if (tags.contains(TagNames.clientPort)) Some(tags(TagNames.clientPort).toInt) else None
AuditEvent(auditSource,
auditType,
"method",
tags.getOrElse("path", ""),
generatedAt,
detail,
eventID = eventId,
requestID = requestId,
sessionID = sessionId,
authorisationToken = authorisationToken,
clientIP = clientIP,
clientPort = clientPort
).withTags(tags.filterNot(tag => TagNames.excludedFromDetail.contains(tag._1)).toArray:_*)
}
}