All Downloads are FREE. Search and download functionalities are using the official Maven repository.

chapi.app.frontend.identify.UmiHttpIdentify.kt Maven / Gradle / Ivy

Go to download

Chapi is A common language meta information convertor, convert different languages to same meta-data model

There is a newer version: 1.5.10
Show newest version
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
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy