Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'scalatra-host' of github.com:scalatra/scalatra into sca…

…latra-host
  • Loading branch information...
commit ebccb4e809e738d8b820a7c8bb4235adff99342b 2 parents 73ccad2 + 9129f5c
@casualjim casualjim authored
View
3  auth/src/main/scala/org/scalatra/auth/Scentry.scala
@@ -5,6 +5,7 @@ import ScentryAuthStore.ScentryAuthStore
import collection.mutable
import grizzled.slf4j.Logger
import org.scalatra.util.RicherString._
+import util.{MapWithIndifferentAccess, MultiMapHeadView}
object Scentry {
@@ -53,7 +54,7 @@ class Scentry[UserType <: AnyRef](
}
//def session = app.session
- def params = app.params
+ def params: Params = app.params
def redirect(uri: String) { app.redirect(uri) }
def register(strategy: => ScentryStrategy[UserType]) {
View
6 core/src/main/scala/org/scalatra/ScalatraBase.scala
@@ -43,6 +43,8 @@ object ScalatraBase {
*/
trait ScalatraSyntax extends CoreDsl with RequestResponseScope with Initializable with ServletApiImplicits with ScalatraParamsImplicits with DefaultImplicitConversions {
import ScalatraBase.{HostNameKey, PortKey, ForceHttpsKey}
+
+
/**
* The routes registered in this kernel.
*/
@@ -325,7 +327,7 @@ trait ScalatraSyntax extends CoreDsl with RequestResponseScope with Initializabl
* Assumes that there is never a null or empty value in multiParams. The servlet container won't put them
* in request.getParameters, and we shouldn't either.
*/
- protected val _params: MultiMapHeadView[String, String] with MapWithIndifferentAccess[String] = new MultiMapHeadView[String, String] with MapWithIndifferentAccess[String] {
+ protected val _params: Params = new MultiMapHeadView[String, String] with MapWithIndifferentAccess[String] {
protected def multiMap = multiParams
}
@@ -333,7 +335,7 @@ trait ScalatraSyntax extends CoreDsl with RequestResponseScope with Initializabl
* A view of `multiParams`. Returns the head element for any known param,
* and is undefined for any unknown param. Invalid outside `handle`.
*/
- def params = _params
+ def params: Params = _params
/**
* Pluggable way to convert a path expression to a route matcher.
View
4 core/src/main/scala/org/scalatra/package.scala
@@ -1,5 +1,7 @@
package org
+import scalatra.util.{MapWithIndifferentAccess, MultiMapHeadView}
+
package object scalatra
extends Control // make halt and pass visible to helpers outside the DSL
// with DefaultValues // make defaults visible
@@ -10,6 +12,8 @@ package object scalatra
type MultiParams = MultiMap
+ type Params = MultiMapHeadView[String, String] with MapWithIndifferentAccess[String]
+
type Action = () => Any
type ErrorHandler = PartialFunction[Throwable, Any]
View
11 core/src/main/scala/org/scalatra/params.scala
@@ -11,10 +11,7 @@ trait ScalatraParamsImplicits {
self: DefaultImplicitConversions =>
- type ParamsType = MultiMapHeadView[String, String] with MapWithIndifferentAccess[String]
- type MultiParamsType = MultiMap
-
- sealed class TypedParams(params: ParamsType) {
+ sealed class TypedParams(params: Params) {
def getAs[T <: Any](name: String)(implicit tc: TypeConverter[String, T]): Option[T] = params.get(name).flatMap(tc.apply(_))
@@ -22,7 +19,7 @@ trait ScalatraParamsImplicits {
}
- sealed class TypedMultiParams(multiParams: MultiParamsType) {
+ sealed class TypedMultiParams(multiParams: MultiParams) {
def getAs[T <: Any](name: String)(implicit tc: TypeConverter[String, T]): Option[Seq[T]] = multiParams.get(name) map {
s =>
@@ -32,9 +29,9 @@ trait ScalatraParamsImplicits {
def getAs[T <: Date](nameAndFormat: (String, String)): Option[Seq[Date]] = getAs(nameAndFormat._1)(stringToDate(nameAndFormat._2))
}
- implicit def toTypedParams(params: ParamsType) = new TypedParams(params)
+ implicit def toTypedParams(params: Params) = new TypedParams(params)
- implicit def toTypedMultiParams(params: MultiParamsType) = new TypedMultiParams(params)
+ implicit def toTypedMultiParams(params: MultiParams) = new TypedMultiParams(params)
}
object ScalatraParamsImplicits extends ScalatraParamsImplicits with DefaultImplicitConversions
View
14 core/src/test/scala/org/scalatra/ParamsExtensionSpec.scala
@@ -10,9 +10,7 @@ class ParamsExtensionSpec extends Specification {
import ScalatraParamsImplicits._
- case class FakeParams(params: Map[String, String]) extends MultiMapHeadView[String, String]
-
- with MapWithIndifferentAccess[String] {
+ case class FakeParams(params: Map[String, String]) extends MultiMapHeadView[String, String] with MapWithIndifferentAccess[String] {
protected def multiMap = MultiMap(params.map(e => (e._1, List(e._2).toSeq)))
}
@@ -20,7 +18,7 @@ class ParamsExtensionSpec extends Specification {
"add a getAs[T] method to Scalatra Params that returns Option[T]" in {
- val params: ParamsType = FakeParams(Map("a" -> "1", "b" -> "", "c" -> null))
+ val params: Params = FakeParams(Map("a" -> "1", "b" -> "", "c" -> null))
params.getAs[Int]("a") must beSome(1)
@@ -34,7 +32,7 @@ class ParamsExtensionSpec extends Specification {
val (format, dateAsText) = ("dd/MM/yyyy", "9/11/2001")
- val params: ParamsType = FakeParams(Map("TwinTowers" -> dateAsText))
+ val params: Params = FakeParams(Map("TwinTowers" -> dateAsText))
val expectedDate = new SimpleDateFormat(format).parse(dateAsText)
@@ -43,7 +41,7 @@ class ParamsExtensionSpec extends Specification {
}
"return None if a conversion is invalid" in {
- val params: ParamsType = FakeParams(Map("a" -> "hello world"))
+ val params: Params = FakeParams(Map("a" -> "hello world"))
params.getAs[Int]("a") must beNone
}
@@ -53,7 +51,7 @@ class ParamsExtensionSpec extends Specification {
implicit val bogusConverter: TypeConverter[String, Bogus] = (s: String) => Some(Bogus(s))
- val params: ParamsType = FakeParams(Map("a" -> "buffybuffy"))
+ val params: Params = FakeParams(Map("a" -> "buffybuffy"))
params.getAs[Bogus]("a") must beSome
@@ -63,7 +61,7 @@ class ParamsExtensionSpec extends Specification {
"explicitely receive a custom TypeConverter" in {
- val params: ParamsType = FakeParams(Map("a" -> "buffybuffy"))
+ val params: Params = FakeParams(Map("a" -> "buffybuffy"))
params.getAs[Bogus]("a")((s: String) => Some(Bogus(s.toUpperCase))) must beSome(Bogus("BUFFYBUFFY"))
View
8 sbt
@@ -4,7 +4,7 @@
# Author: Paul Phillips <paulp@typesafe.com>
# todo - make this dynamic
-declare -r sbt_release_version=0.12.1
+declare -r sbt_release_version=0.12.2-RC1
declare -r sbt_snapshot_version=0.13.0-SNAPSHOT
unset sbt_jar sbt_dir sbt_create sbt_snapshot sbt_launch_dir
@@ -114,7 +114,7 @@ declare -r sbt_opts_file=".sbtopts"
declare -r jvm_opts_file=".jvmopts"
declare -r latest_28="2.8.2"
declare -r latest_29="2.9.2"
-declare -r latest_210="2.10.0-RC5"
+declare -r latest_210="2.10.0"
declare -r script_path=$(get_script_path "$BASH_SOURCE")
declare -r script_dir="$(dirname $script_path)"
@@ -272,6 +272,7 @@ Usage: $script_name [options]
-210 use $latest_210
-scala-home <path> use the scala build at the specified directory
-scala-version <version> use the specified version of scala
+ -binary-version <version> use the specified scala version when searching for dependencies
# java version (default: java from PATH, currently $(java -version |& grep version))
-java-home <path> alternate JAVA_HOME
@@ -355,7 +356,8 @@ process_args ()
-sbt-jar) require_arg path "$1" "$2" && sbt_jar="$2" && shift 2 ;;
-sbt-version) require_arg version "$1" "$2" && sbt_explicit_version="$2" && shift 2 ;;
-sbt-launch-dir) require_arg path "$1" "$2" && sbt_launch_dir="$2" && shift 2 ;;
- -scala-version) require_arg version "$1" "$2" && addSbt "set scalaVersion := \"$2\"" && addSbt "set every scalaBinaryVersion := \"$2\"" && shift 2 ;;
+ -scala-version) require_arg version "$1" "$2" && addSbt "set scalaVersion in ThisBuild := \"$2\"" && shift 2 ;;
+-binary-version) require_arg version "$1" "$2" && addSbt "set scalaBinaryVersion in ThisBuild := \"$2\"" && shift 2 ;;
-scala-home) require_arg path "$1" "$2" && addSbt "set every scalaHome := Some(file(\"$2\"))" && shift 2 ;;
-java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;;
Please sign in to comment.
Something went wrong with that request. Please try again.