Skip to content

Instantly share code, notes, and snippets.

@kgilmer
Created April 13, 2018 15:50
Show Gist options
  • Save kgilmer/8734e5680a94fdd246f5ca513ab6c808 to your computer and use it in GitHub Desktop.
Save kgilmer/8734e5680a94fdd246f5ca513ab6c808 to your computer and use it in GitHub Desktop.
fun fetchFileOrNull(exchange: HttpExchange, basePath: File): File? =
when (validRequest(exchange)) {
true -> {
localFileFromRequestUri(basePath, exchange.requestURI).let { requestedFile ->
if (requestedFile.isFile) requestedFile else null
}
}
false -> null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment