This file contains hidden or 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
| override def onRouteRequest(req: RequestHeader): Option[Action[_]] = | |
| super.onRouteRequest(req).map { | |
| case action: Action[_] => | |
| currentUserId(req) match { | |
| case None => | |
| req.path match { | |
| case p if isRestrictedPath(p) => // requires login | |
| Authenticated(action) | |
| case p if isEncryptedWhenLoggedOut(p) => // required HTTPS for user/ | |
| Encrypted(action) |
This file contains hidden or 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
| protected case class Encrypted[A](action: Action[A]) extends Action[A] { | |
| def apply(req: Request[A]) = { | |
| EnvUtil.isCloud match { | |
| case true => | |
| req.headers.get("x-forwarded-proto") match { | |
| case Some("https") => action(req) | |
| case _ => redirectToHttps(req) | |
| } | |
| case _ => |
This file contains hidden or 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
| #logs | |
| *.log | |
| logs/ | |
| logs/** | |
| tmp/ | |
| tmp/** | |
| #assets | |
| *.ai | |
| *.psd |
This file contains hidden or 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
| import org.slf4j._ | |
| lazy val log = LoggerFactory.getLogger(loggerName) | |
| Session.currentSession.setLogger(logging(_)) | |
| def logging(msg: String) { | |
| if (log.isDebugEnabled) { | |
| val _m = msg.replaceAll("\n", " ").replaceAll(" ", " ").replaceAll(" ", " ") |
This file contains hidden or 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
| <table> | |
| <tbody> | |
| <!-- first 'section' --> | |
| <tr class="head"> | |
| <td colspan="4">HEAD A</td> | |
| </tr> | |
| <tr class="data"> | |
| <td>a</td> |
This file contains hidden or 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
| <table> | |
| <tbody> | |
| <!-- first 'section' --> | |
| <tr class="head"> | |
| <td>HEAD A</td> | |
| <td></td> | |
| </tr> | |
| <tr class="data"> |
This file contains hidden or 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
| private def shrinkDBO(dbo: DBObject): DBObject = { | |
| def isDBO(v: AnyRef) = v.isInstanceOf[DBObject] | |
| def isEmptyDBO(v: AnyRef) = isDBO(v) && v.asInstanceOf[DBObject].isEmpty | |
| def shrink(v: AnyRef) = if (isDBO(v)) shrinkDBO(v.asInstanceOf[DBObject]) else v | |
| dbo match { | |
| case _: BasicDBList => | |
| val ls = new BasicDBList() | |
| (dbo.mapValues(shrink(_)).filter(!isEmptyDBO(_)).values).foreach(ls.add(_)) | |
| ls |
This file contains hidden or 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
| import akka.amqp.AMQP._ | |
| import akka.amqp._ | |
| import akka.actor._ | |
| import akka.dispatch._ | |
| import akka.util.Logging | |
| object AMQPTest extends Logging { | |
| val connection = AMQP.newConnection() | |
| val exchangeParameters = ExchangeParameters("my_direct_exchange", Direct) |
This file contains hidden or 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
| import akka.amqp.AMQP._ | |
| import akka.amqp._ | |
| import akka.actor._ | |
| import akka.dispatch._ | |
| import akka.util.Logging | |
| object AMQPTest extends Logging { | |
| val connection = AMQP.newConnection() | |
| val exchangeParameters = ExchangeParameters("my_direct_exchange", Direct) |
This file contains hidden or 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
| object AMQPTest extends Logging { | |
| val connection = AMQP.newConnection() | |
| val exchangeParameters = ExchangeParameters("my_direct_exchange", Direct) | |
| class JobConsumer extends Actor { | |
| def receive = { | |
| case Delivery(payload, _, _, _, _, _) => | |
| println("Received message: " + new String(payload)) |