Permalink
Browse files

cleanup

  • Loading branch information...
1 parent b46de6b commit 92a83bf225e811c38d429a53b86af080dd5159b3 marius committed Mar 14, 2011
@@ -23,7 +23,7 @@ object Application extends BootConfig {
override def rewrite = cfg.rewrite
override def contextPath = cfg.contextPath
- override def handleRequest = cfg.handleRequest
+ override def handleRequest(req: Request) = cfg.handleRequest(req)
override def templateLookupSuffixes = cfg.templateLookupSuffixes
override def siteMap = cfg.siteMap
@@ -14,11 +14,9 @@ trait BootConfig {
case req => req.contextPath
}
- def handleRequest : (Request) => Boolean = (req) => {
- req.path match {
- case Path("static" :: _, _) => false
- case _ => true
- }
+ def handleRequest(req: Request) : Boolean = req.path match {
+ case Path("static" :: _, _) => false
+ case _ => true
}
def templateLookupSuffixes: List[String] = "html" :: "htm" :: Nil
@@ -26,6 +26,6 @@ private[http] object Server extends Reader {
}
-case class ServerState(req: Request,
- respStatus: Int,
- error: Option[Exception])
+case class PipeLine(req: Request,
+ respStatus: Int,
+ error: Option[Exception])
@@ -7,21 +7,9 @@ import util._
import State._
trait Reader {
- def read = new Generator[Request, Option] {
- def unit[B](b: B): Option[B] = {
- if (b != null) Some(b) else None
- }
- def filter(f: Request => Boolean): Generator[Request, Option] = {
- this
- }
- }
+ def readRequest = state[Request, PipeLine](s => (s.req, s))
- def readRequest = state[Request, ServerState](s => (s.req, s))
-
- def template(n: Option[NodeSeq]) = state[NodeSeq, ServerState](s => n match {
- case Some(node) => (n, s)
- case _ =>
- })
+ def template(n: NodeSeq) = state[NodeSeq, PipeLine](s => (n, s))
}
@@ -15,7 +15,7 @@ import util._
import Util._
class ShiftFilter extends Filter {
- private var continuation : State[Response, ServerState] = _
+ private var continuation : State[Response, PipeLine] = _
def init(config: FilterConfig) {
Server.boot(new ServletContext(config.getServletContext))
@@ -27,9 +27,8 @@ class ShiftFilter extends Filter {
def doFilter(req: SReq, res: SResp, chain: FilterChain) {
val request = new ServletRequest(req.asInstanceOf[HttpServletRequest])
- continuation(ServerState(request, 200, None)) match {
+ continuation(PipeLine(request, 200, None)) match {
case (resp, _) => toServletResponse(resp, res.asInstanceOf[HttpServletResponse])
- //case _ => chain.doFilter(req, res)
}
}
@@ -46,34 +46,6 @@ class Scope[T] {
}
-trait Generator[A, M[_]] {
-
- type Cont[T] = A => M[T]
-
- def unit[B](b: B): M[B]
- def map[B](f: A => B): Cont[B] = f andThen unit
- def flatMap[B](f: A => M[B]): Cont[B] = f
-
- def filter(f: A => Boolean): Generator[A, M]
-}
-
-trait Functor[A] {
-
- type M[A] <: Functor[A]
-
- def unit[B](b: B): M[B]
-
- //def fmap[B](f: A => B): M[A] => M[B]
-}
-
-trait Monad[A] extends Functor[A] {
-
- type M[A] <: Monad[A]
-
- def bind[B](m: M[A])(f: A => M[B]): M[B]
-
-}
-
class Cont[R, A](val in: (A => R) => R) {
type M[R, A] = Cont[R, A]
@@ -108,11 +80,6 @@ object State {
def unit[A, S](a: A) = new State[A, S](s => (a, s))
- def modify[S](f: S => S) = state[Unit, S](s => ((), f(s)))
-
- def modifyPf[S](f: PartialFunction[S, S]) =
- state[Unit, S](s => ((), if (f isDefinedAt s) f(s) else s))
-
def compute[B, S](f: S => B) = new State[B, S](s => (f(s), s))
}
@@ -142,20 +109,6 @@ class State[+A, S](val in: S => (A, S)) extends StateFunctor[A, S] {
def map[B](f: A => B): M[B, S] = bind(this)(unit[B] _ compose f)
-}
-
-
-import http._
-import java.io.InputStream
-import shiftdefs._
-
-object Main3 {
-
- def unit[R, B](b: B): Cont[R, B] = new Cont[R, B](a => a(b))
-
- def state[B, S](b: B): State[B, S] = new State[B, S](s => (b, s))
-
- def modifyState[A, S](a: A)(f : S => S): State[A, S] =
- new State[A, S](s => (a, f(s)))
+}

0 comments on commit 92a83bf

Please sign in to comment.