INNER CODE UNIT · Python

build_curl

Far-Se/tabame · plugins/api-client/main.py:256

def build_curl(entry):
    parts = [
        "curl",
        "-X",
        entry.get("method", "GET"),
        shlex.quote(entry.get("url", "")),
    ]
    url = entry.get("url", "")
    params = entry.get("params") or {}
    if params:
        sep = "&" if "?" in url else "?"
        parts[-1] = shlex.quote(f"{url}{sep}{urlencode(params)}")
    for k, v in (entry.get("headers") or {}).items():
        parts += ["-H", shlex.quote(f"{k}: {v}")]
    auth_type = entry.get("authType", "none")
    auth = entry.get("auth") or {}
    if auth_type == "bearer" and auth.get("token"):
        parts += ["-H", shlex.quote(f"Authorization: Bearer {auth['token']}")]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…