Skip to content

Instantly share code, notes, and snippets.

@kgilmer
Created April 13, 2018 15:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgilmer/4897c5ff1cfdada62b485bc93d9f0ce3 to your computer and use it in GitHub Desktop.
Save kgilmer/4897c5ff1cfdada62b485bc93d9f0ce3 to your computer and use it in GitHub Desktop.
fun fetchFileOrNull(exchange: HttpExchange, basePath: File): File? =
when (validRequest(exchange)) {
true -> {
val resource = localFileFromRequestUri(basePath, exchange.requestURI)
print("Seeking ${resource.absolutePath}...")
if (resource.isFile) resource else null
}
false -> null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment