-
-
Save daviddenton/6c6ca879e96f66779f394ca7a200983b 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
import org.http4k.client.ApacheClient | |
import org.http4k.core.HttpHandler | |
import org.http4k.core.Method.POST | |
import org.http4k.core.Request | |
import org.http4k.core.Response | |
import org.http4k.core.Status.Companion.OK | |
import org.http4k.server.Jetty | |
import org.http4k.server.asServer | |
fun main() { | |
val app: HttpHandler = { req: Request -> | |
println("HEADER WAS: " + req.header("foobar")) | |
Response(OK).body(req.body.stream) | |
} | |
val server = app.asServer(Jetty(10000)).start() | |
val request = Request(POST, "http://localhost:10000") | |
.header("foobar", "headervalue") | |
.body("hello".byteInputStream()) | |
println("Response was: " + ApacheClient()(request).bodyString()) | |
server.stop() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment