Skip to content

Commit

Permalink
can remove the IMap alias, all maps in this file are immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Hamblen committed Oct 29, 2011
1 parent 6b83bd7 commit 24dac96
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions core/src/main/scala/handlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import java.util.zip.GZIPInputStream
import java.io.{InputStream,OutputStream,InputStreamReader}
import javax.xml.parsers.SAXParserFactory
import scala.io.Source
import collection.immutable.{Map => IMap}
import util.control.Exception._

/** Request handler, contains request descriptor and a function to transform the result. */
Expand Down Expand Up @@ -99,9 +98,9 @@ class HandlerVerbs(request: Request) {
}
/** Process header as Map in block. Map returns empty set for header
* name misses. */
def >:> [T] (block: IMap[String, Set[String]] => T) = {
def >:> [T] (block: Map[String, Set[String]] => T) = {
Handler(request, { (_, res, _) =>
val st = IMap.empty[String, Set[String]].withDefaultValue(Set.empty)
val st = Map.empty[String, Set[String]].withDefaultValue(Set.empty)
block((st /: res.getAllHeaders) { (m, h) =>
m + (h.getName -> (m(h.getName) + h.getValue))
})
Expand All @@ -110,9 +109,9 @@ class HandlerVerbs(request: Request) {

/** Process headers as a Map of strings to sequences of *lowercase*
* strings, to facilitate case-insensetive header lookup. */
def headers_> [T] (block: IMap[String, Seq[String]] => T) = {
def headers_> [T] (block: Map[String, Seq[String]] => T) = {
Handler(request, { (_, res, _) =>
val st = IMap.empty[String, Seq[String]].withDefaultValue(Seq.empty)
val st = Map.empty[String, Seq[String]].withDefaultValue(Seq.empty)
block((st /: res.getAllHeaders) { (m, h) =>
val key = h.getName.toLowerCase
m + (key -> (m(key) :+ h.getValue))
Expand All @@ -123,7 +122,7 @@ class HandlerVerbs(request: Request) {
/** Combination header and request chaining verb. Headers are
* converted to lowercase for case insensitive access.
*/
def >:+ [T] (block: (IMap[String, Seq[String]], Request) =>
def >:+ [T] (block: (Map[String, Seq[String]], Request) =>
Handler[T]) =
>+> { req =>
req headers_> { hs => block(hs, req) }
Expand Down

0 comments on commit 24dac96

Please sign in to comment.