This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class ErrorAwareOptional[E, S, T, A, B] private (underlying: POptional[Either[E, S], Either[E, T], Either[E, A], Either[E, B]]) { | |
self => | |
def errorAs[E1 >: E] = self.asInstanceOf[ErrorAwareOptional[E1, S, T, A, B]] | |
def andThen[C, D](other: POptional[A, B, C, D]): ErrorAwareOptional[E, S, T, C, D] = { | |
val lifted: ErrorAwareOptional[E, A, B, C, D] = lift(other).errorAs[E] | |
self.andThen(lifted) | |
} | |
def andThen[E1 >: E, C, D](other: ErrorAwareOptional[E1, A, B, C, D]): ErrorAwareOptional[E1, S, T, C, D] = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Entity[E <: Entity[E]] | |
sealed case class Forward[FROM <: Entity[FROM], TO <: Entity[TO]](from: FROM, to: TO) | |
trait EntityRef[FROM <: Entity[FROM], TO <: Entity[TO]] { self => | |
def ref(entity: TO) : Forward[FROM, TO] | |
} | |
trait UserRef[FROM <: Entity[FROM]] extends EntityRef[FROM, User] { self: Entity[FROM] => | |
override def ref(entity: User): Forward[UserRef[FROM] with Entity[FROM], User] = Forward(self, entity) | |
} | |
trait GroupRef[FROM <: Entity[FROM]] extends EntityRef[FROM, Group] { self: Entity[FROM] => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait RequestRateLimiter[T] { | |
def check(ctx: RequestContext, realIp: Option[RemoteAddress], proxiedIp: Option[RemoteAddress]) : RequestRateResult[T] | |
} | |
sealed trait RequestRateResult[T] | |
case class Pass[T](result: T) extends RequestRateResult[T] | |
case class Block[T](rejection: Rejection) extends RequestRateResult[T] | |
def limit[T](requestRateLimiter: RequestRateLimiter[T]): Directive1[T] = { | |
def remoteAddress: Directive1[Option[RemoteAddress]] = optionalHeaderValuePF { case `Remote-Address`(address) ⇒ address } |