Permalink
Browse files

Merge pull request #20 from franklinhu/pass_controllers

Pass controllers into AppService
  • Loading branch information...
2 parents 66a3031 + f2737b3 commit a60fd530201338b6812258d5123b330b448afb19 @capotej capotej committed Aug 8, 2012
@@ -16,6 +16,7 @@
package com.twitter.finatra
import com.twitter.finagle.{Service, SimpleFilter}
+import com.twitter.finatra_core.ControllerCollection
import com.twitter.util.Future
import org.jboss.netty.buffer.ChannelBuffers.copiedBuffer
import org.jboss.netty.handler.codec.http._
@@ -24,7 +25,8 @@ import org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1
import org.jboss.netty.util.CharsetUtil.UTF_8
-class AppService extends Service[HttpRequest, HttpResponse]{
+class AppService(controllers: ControllerCollection[Request, Future[Response], Future[HttpResponse]])
+ extends Service[HttpRequest, HttpResponse]{
def notFoundResponse = {
val resp = new DefaultHttpResponse(HTTP_1_1, NOT_FOUND)
@@ -35,7 +37,7 @@ class AppService extends Service[HttpRequest, HttpResponse]{
def apply(rawRequest: HttpRequest) = {
val request = RequestAdapter(rawRequest)
- FinatraServer.controllers.dispatch(request) match {
+ controllers.dispatch(request) match {
case Some(response) =>
response.asInstanceOf[Future[HttpResponse]]
case None =>
@@ -51,7 +51,7 @@ object FinatraServer extends Logging {
this.docroot = docroot
this.pidPath = pidPath
- val appService = new AppService
+ val appService = new AppService(controllers)
val fileService = new FileService
val envPort = Option(System.getenv("PORT"))

0 comments on commit a60fd53

Please sign in to comment.