I want a single server that pretends to be several...
# http4k
d
I want a single server that pretends to be several others. With your help I’ve got to this
Copy code
fun hostContains(s: String) = { request: Request -> request.header("host")?.contains(s) ?: false }.asRouter()

val routes = routes(
    hostContains("<http://value-elf.com|value-elf.com>") bind routes(
        GET to { request -> Response(OK).body("hello from value-elf") }
    ),
    hostContains("<http://priceomatic.com|priceomatic.com>") bind routes(
        GET to { request -> Response(OK).body("hello from priceomatic") }
    ),
    hostContains("<http://webuyanymagicalitem.com|webuyanymagicalitem.com>") bind routes(
        GET to { request -> Response(OK).body("hello from webuyanymagicalitem") }
    ),
)
which is enough to get me through the next video!