chapi.app.frontend.identify.UmiHttpIdentify.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of chapi-application Show documentation
Show all versions of chapi-application Show documentation
Chapi is A common language meta information convertor, convert different languages to same meta-data model
package chapi.app.frontend.identify
import chapi.app.frontend.ContainerDemand
import chapi.domain.core.CodeCall
import chapi.domain.core.CodeImport
class UmiHttpIdentify : HttpIdentify {
override fun isMatch(call: CodeCall, imports: Array): Boolean {
val imps = imports.filter { it.Source == "umi-request" }
if (imps.isEmpty()) {
return false
}
if (call.FunctionName == "request") {
return true
}
return false
}
override fun convert(call: CodeCall): ContainerDemand {
val url = call.Parameters[0].TypeValue
val httpApi = ContainerDemand(target_url = url)
for (codeProperty in call.Parameters[1].ObjectValue) {
when (codeProperty.TypeValue) {
"method" -> {
httpApi.target_http_method = codeProperty.ObjectValue[0].TypeValue
}
"data" -> {
httpApi.call_data = codeProperty.ObjectValue[0].TypeValue
}
}
}
return httpApi
}
}