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
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.FunSuite | |
import javax.servlet.http.{HttpServletResponse, HttpServletRequest, HttpServlet} | |
import java.net.URLEncoder | |
import org.mortbay.jetty.testing.{HttpTester, ServletTester} | |
class CharsetServlet extends HttpServlet { | |
override def doGet(req: HttpServletRequest, res: HttpServletResponse) = { | |
val foo = req.getParameter("foo") | |
res.setContentType("text/plain; charset=utf-8") |
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
// I think this is possible, if we just ignore the names. | |
// | |
// year = :year, month = :month, day = :day | |
get("/date/:year/:month/:day") { (year, month, day) => | |
<ul> | |
<li>Year: { year }</li> | |
<li>Month: { month }</li> | |
<li>Day: { day }</li> | |
</ul> | |
} |
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
override def ivyXML = | |
<configurations defaultconfmapping="*->default(compile)"> | |
<conf name="compile" /> | |
<conf name="runtime" extends="compile" /> | |
<conf name="test" extends="runtime" /> | |
<conf name="provided" /> | |
</configurations> | |
override def defaultConfigurationExtensions = false |
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
scala> null == 42 | |
res0: Boolean = false | |
scala> (null:java.lang.Integer) == 42 | |
java.lang.NullPointerException | |
at scala.runtime.BoxesRunTime.equalsNumNum(Unknown Source) | |
at scala.runtime.BoxesRunTime.equalsNumObject(Unknown Source) | |
at .<init>(<console>:6) | |
at .<clinit>(<console>) | |
at RequestResult$.<init>(<console>:9) |
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
final class RichAnyRef[T <:AnyRef](val value: T) extends Proxy { | |
def self: Any = value | |
def ? : Option[T] = Option(value) | |
def ?[R] ( func: (T=>R) ) : Option[R] = Option(value) map func | |
} | |
implicit def RichAnyRefWrapper[T <:AnyRef](x: T) = new RichAnyRef(x) | |
final class RichOption[T](val value: Option[T]) extends Proxy { | |
def self: Any = value | |
def | (other:T): T = value.getOrElse(other) |
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
scala> import org.scalatra.ssgi._ | |
import org.scalatra.ssgi._ | |
scala> val res = Response(body = "foo") | |
res: org.scalatra.ssgi.Response[java.lang.String] = Response(200,Map(),foo) | |
scala> res map { _.toUpperCase } | |
res10: org.scalatra.ssgi.Response[java.lang.String] = Response(200,Map(),FOO) | |
scala> res map { x => <h1>{x}</h1> } |
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 AuthenticationSupport | |
extends ScentrySupport[ApiUser] | |
with FlashMapSupport | |
with CookieSupport | |
with Logging { self: ScalatraKernel => | |
before { scentry.authenticate('RememberMe) } | |
override protected def registerAuthStrategies = { | |
scentry.registerStrategy('UserPassword, app => new UserPasswordStrategy(app)) |
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 ScalatraTestDependencies extends BasicManagedProject { | |
def testProjectDependencies = List(scalatest, specs) | |
abstract override def dependencies = super.dependencies.toList ++ testProjectDependencies | |
override def deliverProjectDependencies: Iterable[ModuleID] = { | |
val testDependencyIds = testProjectDependencies.map(_.projectID).toList | |
super.deliverProjectDependencies.toList -- testDependencyIds ++ (testDependencyIds map { _ % "test" }) | |
} |
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
implicit def writesToWriterToCharRenderable(writesToWriter: { def writeTo(writer: Writer): Unit }) = | |
new CharRenderable { | |
def writeTo(out: OutputStream, cs: Charset) { writeTo(new OutputStreamWriter(out, cs)) } | |
def writeTo(writer: Writer) { writesToWriter.writeTo(writer) } | |
} |
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
package com.mojolly.websocket | |
import akka.actor.{Scheduler, Actor} | |
import java.util.concurrent.TimeUnit | |
import Actor._ | |
import org.jredis.ri.alphazero.JRedisClient | |
/* | |
* Gets executed by the listener defined in web.xml | |
*/ |
OlderNewer