@@ -34,6 +34,7 @@ class PluginApiResourceHandler(val project: Project) : CefResourceHandler {
3434 override fun processRequest (request : CefRequest , callback : CefCallback ): Boolean {
3535 Log .log(logger::trace, " processing request {}, [request id:{}]" , request.url, request.identifier)
3636
37+ // todo: we don't support multi part form data yet or file elements in the post data
3738 if ((request.postData?.elementCount ? : - 1 ) > 1 ) {
3839 Log .log(
3940 logger::warn,
@@ -49,9 +50,6 @@ class PluginApiResourceHandler(val project: Project) : CefResourceHandler {
4950
5051
5152 if (hasFileElements(request.postData)) {
52-
53- // todo: we don't support multi part form data yet or file elements in the post data
54-
5553 Log .log(
5654 logger::warn,
5755 " encountered file element in post data. it is not supported by Digma plugin api handler, [request id:{}]" ,
@@ -95,15 +93,21 @@ class PluginApiResourceHandler(val project: Project) : CefResourceHandler {
9593
9694 val apiUrl = URI (requestUrl).toURL()
9795
98- apiResponse = getCommand(apiUrl)?.let { command ->
99- Log .log(logger::trace, " executing command {}, [request id:{}]" , command, requestId)
100- command.execute(project, requestId, requestMethod, postData, headers)
96+ val command = getCommand(apiUrl)
97+ if (command == null ) {
98+ Log .log(logger::trace, " command not found for url {}, [request id:{}]" , requestUrl, requestId)
99+ val error = ErrorData (" command not found for url [$requestUrl ]" )
100+ apiResponse = PluginApiHttpResponse .createErrorResponse(404 , error)
101+ return
101102 }
103+
104+ Log .log(logger::trace, " executing command {}, [request id:{}]" , command.javaClass.name, requestId)
105+ apiResponse = command.execute(project, requestId, requestMethod, postData, headers)
102106 Log .log(logger::trace, " got api response {}, [request id:{}]" , apiResponse, requestId)
103107
104108 } catch (e: Throwable ) {
105109 Log .warnWithException(logger, e, " processRequest {} failed, [request id:{}]" , requestUrl, requestId)
106- ErrorReporter .Companion .getInstance().reportError(" ApiProxyResourceHandler .processRequest" , e)
110+ ErrorReporter .Companion .getInstance().reportError(" PluginApiResourceHandler .processRequest" , e)
107111
108112 val error = ErrorData (" encountered exception in plugin api handler [$e ]. please check the logs." )
109113 apiResponse = PluginApiHttpResponse .createErrorResponse(500 , error)
0 commit comments