View layout in progress

This commit is contained in:
Claude Brisson
2023-06-11 13:52:15 +02:00
parent c9d812260a
commit a8d4649404
14 changed files with 129 additions and 48 deletions

View File

@@ -40,7 +40,7 @@ class FileStore(pathStr: String): StoreImplementation {
return path.useDirectoryEntries("*.tour") { entries ->
entries.mapNotNull { entry ->
filenameRegex.matchEntire(entry.fileName.toString())?.groupValues?.get(1)?.toID()
}.toSet()
}.toSortedSet()
}
}

View File

@@ -170,7 +170,7 @@ class ApiServlet : HttpServlet() {
}
// check charset
if (charset != null && EXPECTED_CHARSET != charset) throw ApiException(
if (charset != null && EXPECTED_CHARSET != charset.lowercase(Locale.ROOT).replace("-", "")) throw ApiException(
HttpServletResponse.SC_BAD_REQUEST,
"UTF-8 content expected"
)
@@ -215,6 +215,8 @@ class ApiServlet : HttpServlet() {
HttpServletResponse.SC_BAD_REQUEST,
"Missing 'Accept' header"
)
// CB TODO 1) a reference to a specific API call at this point is a code smell.
// 2) there will e other content types: .tou, .h9, .html
if (!isJson(accept) && (!isXml(accept) || !request.requestURI.matches(Regex("/api/tour/\\d+")))) throw ApiException(
HttpServletResponse.SC_BAD_REQUEST,
"Invalid 'Accept' header"