Skip to content

Commit

Permalink
micro apps
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddenton committed Aug 29, 2018
1 parent 4e57e56 commit 97cc036
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
23 changes: 13 additions & 10 deletions src/docs/cookbook/micro_apps/example.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.http4k.routing.ResourceLoader.Companion.Directory
import org.http4k.routing.static
import org.http4k.server.SunHttp
import org.http4k.server.asServer
import org.http4k.traffic.Replay
import org.http4k.traffic.Sink.Companion.DiskTree

fun `traffic sniffing proxy`() {
Expand All @@ -20,6 +21,13 @@ fun `traffic sniffing proxy`() {
.block()
}

fun `static file server`() {
static(Directory())
.asServer(SunHttp(10000))
.start()
.block()
}

fun `recording traffic to disk proxy`() {
RecordTo(DiskTree())
.then(ProxyHost())
Expand All @@ -29,13 +37,8 @@ fun `recording traffic to disk proxy`() {
.block()
}

fun `static file server`() {
static(Directory())
.asServer(SunHttp(10000))
.start()
.block()
}

fun main(args: Array<String>) {
`static file server`()
}
fun `replay previously recorded traffic from a disk store`() {
JavaHttpClient().let { client ->
Replay.DiskStream().requests().forEach { client(it) }
}
}
4 changes: 1 addition & 3 deletions src/docs/cookbook/record_and_replay/example_stream.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,5 @@ fun main(args: Array<String>) {

// we can also replay a series of requests through a real HTTP client
val client = ApacheClient()
for (request in storage.requests()) {
println(client(request))
}
storage.requests().forEach { println(client(it)) }
}

0 comments on commit 97cc036

Please sign in to comment.