diff --git a/docker/test.sh b/docker/test.sh new file mode 100755 index 0000000..eafa7ec --- /dev/null +++ b/docker/test.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +curl -s -D - --header "Accept: application/json" http://localhost:8080/api/tournament + +curl -s --header "Accept: application/json" --header "Content-Type: application/json" \ + --request POST \ + --data '{"type":"INDIVIDUAL","name":"Mon Tournoi", "shortName": "mon-tournoi", "startDate": "2023-05-10", "endDate": "2023-05-12", "country": "FR", "location": "Marseille", "online": false, "timeSystem": { "type": "fisher", "mainTime": "1200", "increment": "10" }, "pairing": { "type": "ROUNDROBIN" } }' \ + http://localhost:8080/api/tournament + +curl -s -D - --header "Accept: application/json" http://localhost:8080/api/tournament/1 + diff --git a/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt b/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt index 8a5d8b7..0a850d7 100644 --- a/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt +++ b/src/main/kotlin/org/jeudego/pairgoth/web/ApiServlet.kt @@ -41,6 +41,9 @@ class ApiServlet : HttpServlet() { } private fun doRequest(request: HttpServletRequest, response: HttpServletResponse) { + val uri = request.requestURI + logger.logRequest(request, !uri.contains(".") && uri.length > 1) + var payload: Json? = null var reason = "OK" try { @@ -49,8 +52,6 @@ class ApiServlet : HttpServlet() { } validateContentType(request) validateAccept(request); - val uri = request.requestURI - logger.logRequest(request, !uri.contains(".") && uri.length > 1) val parts = uri.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray() if (parts.size < 3 || parts.size > 5) throw ApiException(HttpServletResponse.SC_BAD_REQUEST)