Any tricks to debug why a request is never called?...
# http4k
c
Any tricks to debug why a request is never called? (the server answers with a 404, the request body is never called). I guess it's some kind of routing issue, but I don't see the difference with our other examples. Is there some equivalent of Ktor's
traceRouting
to log what the routing algorithm checks?
s
You could add a
DebuggingFilters.PrintRequest
or similar filter at the top level to intercept all requests and log/debug as needed
c
Is it supposed to print anything more than this?
Copy code
***** REQUEST: GET: <URL> *****
s
You could copy it to print etc to your needs
c
I know what request I'm making, I don't know why http4k doesn't route it to the execution block
s
are you using path params? I had an issue recently where the syntax is different between simple routing and using the Contracts-based routes
c
Yes, the route looks like
/api/{id}
s
are you using the Contracts routes? ie, generating the Swagger using Http4k like here?
c
…nevermind, found it. I was calling the endpoint with the wrong method.
s
ah ok. easily done
c
I wish the lib would give more info on what's going on internally…
d
The toString of any RoutedHttpHandler will give you the routing tree description which you can put through something like Jackson to give you an idea of the overall tree:
Copy code
println(Jackson.prettify(Jackson.asFormatString(bhttp)))
It cannot however, account for PEBKAC. 🙃
🤯 2
n
Hi I have (had) a route which worked and, after transforming it into a ContractRoute, has stopped working. If I print the routed http handler I got this: { "description" : { "description" : "/api/v0.0.1", "children" : [ { "description" : "/POST: /mav-request-batch/openapi.json/mav-request-batch", "children" : [ ] }, { "description" : "/GET: /{vendorType}/health-check/openapi.json/{vendorType}/health-check", "children" : [ ] } ] } } The second path does not work, the first works. If I call the second with GET http://localhost:9012/api/v0.0.1/BPOPSO/health-check I got in the backend: ***** REQUEST: GET: /api/v0.0.1/BPOPSO/health-check ***** GET /api/v0.0.1/BPOPSO/health-check HTTP/1.1 Host: localhost:9012 <<stream>> ***** RESPONSE 404 to GET: /api/v0.0.1/BPOPSO/health-check ***** HTTP/1.1 404 Route not found I don't understand whats wrong here ...
don't know if it's another form of a PEBKAC ...