Skip to content

Instantly share code, notes, and snippets.

@kgilmer
Created April 13, 2018 15:47
Show Gist options
  • Save kgilmer/839c81415eb36065ab7dc4dd647672d1 to your computer and use it in GitHub Desktop.
Save kgilmer/839c81415eb36065ab7dc4dd647672d1 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