-
-
Save stonegao/5806919 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.twitter.dumproxy | |
import com.twitter.finagle.Service | |
import org.jboss.netty.handler.codec.http._ | |
import java.net.InetSocketAddress | |
import com.twitter.finagle.builder.{ClientBuilder, Server, ServerBuilder} | |
import com.twitter.finagle.http.Http | |
object App { | |
class RequestReceiver extends Service[HttpRequest, HttpResponse] { | |
def apply(request: HttpRequest) = { | |
val client: Service[HttpRequest, HttpResponse] = ClientBuilder() | |
.codec(Http()) | |
.hosts(request.getHeader("Host") + ":80") | |
.hostConnectionLimit(1) | |
.build() | |
client.apply(request) | |
} | |
} | |
def main(args: Array[String]) { | |
val recv = new RequestReceiver | |
val myService: Service[HttpRequest, HttpResponse] = recv | |
val server: Server = ServerBuilder() | |
.codec(Http()) | |
.bindTo(new InetSocketAddress(8080)) | |
.name("httpserver") | |
.build(myService) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment