Debug API

This commit is contained in:
Claude Brisson
2023-05-11 16:35:38 +02:00
parent a42d591d03
commit 7d246ee0a0
2 changed files with 14 additions and 2 deletions

11
docker/test.sh Executable file
View File

@@ -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

View File

@@ -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)