Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (18 sloc) 646 Bytes
package cookbook.nanoservices
import org.http4k.client.JavaHttpClient
import org.http4k.core.Method.GET
import org.http4k.core.Request
import org.http4k.routing.ResourceLoader.Companion.Directory
import org.http4k.routing.static
import org.http4k.server.SunHttp
import org.http4k.server.asServer
fun `static file server`() =
static(Directory())
.asServer(SunHttp())
.start()
fun main() {
`static file server`().use {
// by default, static servers will only serve known file types, or those registered on construction
println(JavaHttpClient()(Request(GET, "http://localhost:8000/version.json")))
}
}