Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: twitter/finatra
...
head fork: twitter/finatra
Checking mergeability… Don't worry, you can still create the pull request.
  • 1 commit
  • 2 files changed
  • 0 commit comments
  • 1 contributor
View
7 src/main/scala/com/twitter/finatra/AppService.scala
@@ -26,7 +26,6 @@ class AppService(controllers: ControllerCollection)
def apply(rawRequest: FinagleRequest) = {
val adaptedRequest = RequestAdapter(rawRequest)
- val responseConverter = new FinatraResponseConverter
try {
attemptRequest(rawRequest)
@@ -34,19 +33,19 @@ class AppService(controllers: ControllerCollection)
case e: Exception =>
logger.error(e, "Internal Server Error")
adaptedRequest.error = Some(e)
- responseConverter(controllers.errorHandler(adaptedRequest))
+ ResponseAdapter(controllers.errorHandler(adaptedRequest))
}
}
def attemptRequest(rawRequest: FinagleRequest) = {
val adaptedRequest = RequestAdapter(rawRequest)
- val responseConverter = new FinatraResponseConverter
+
controllers.dispatch(rawRequest) match {
case Some(response) =>
response.asInstanceOf[Future[FinagleResponse]]
case None =>
- responseConverter(controllers.notFoundHandler(adaptedRequest))
+ ResponseAdapter(controllers.notFoundHandler(adaptedRequest))
}
}
View
9 ...om/twitter/finatra/FinatraResponseConverter.scala → ...n/scala/com/twitter/finatra/ResponseAdapter.scala
@@ -18,8 +18,15 @@ package com.twitter.finatra
import com.twitter.util.Future
import com.twitter.finagle.http.{Response => FinagleResponse}
+object ResponseAdapter {
+ def apply(resp: Future[Response]) = {
+ val adapter = new FinatraResponseConverter
+ adapter(resp)
+ }
+}
+
class FinatraResponseConverter {
- def apply(resp: Future[Response]):Future[FinagleResponse] = {
+ def apply(resp: Future[Response]): Future[FinagleResponse] = {
resp.map(_.build)
}
}

No commit comments for this range

Something went wrong with that request. Please try again.