{"id":16767865,"url":"https://github.com/eolinker/goku-plugin-params_transformer","last_synced_at":"2025-08-18T12:05:29.324Z","repository":{"id":103579815,"uuid":"208740426","full_name":"eolinker/Goku-plugin-params_transformer","owner":"eolinker","description":"GOKU API GATEWAY 官方插件：参数映射","archived":false,"fork":false,"pushed_at":"2019-09-19T02:25:43.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T17:01:37.396Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eolinker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-16T07:45:59.000Z","updated_at":"2023-07-25T14:29:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"63d45c81-9421-4552-9176-799d57cd4cda","html_url":"https://github.com/eolinker/Goku-plugin-params_transformer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-params_transformer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-params_transformer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-params_transformer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eolinker%2FGoku-plugin-params_transformer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eolinker","download_url":"https://codeload.github.com/eolinker/Goku-plugin-params_transformer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248281382,"owners_count":21077423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T06:10:09.727Z","updated_at":"2025-04-10T19:21:12.780Z","avatar_url":"https://github.com/eolinker.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Goku Plugin：Params Transformer\n\n| 插件名称  | 文件名.so |  插件类型  | 错误处理方式 | 作用范围 |  优先级  |\n| ------------ | ------------ | ------------ | ------------ | ------------ | ------------ |\n| 参数映射  | goku-params_transformer | 访问策略 | 继续后续操作 | 转发前  | 801 |\n\n实现表单或json参数的映射，访问API的 **参数A** 绑定到目标API的 **参数B**，映射位置包括header、body、query。\n\n注意事项：\n* 若访问API的参数名是user，目标API的参数名是username，此时需开启参数映射插件；若均为username，则无需开启此插件。\n* json仅支持 **一级** 映射。\n* 若参数类型为表单时，映射插件支持同名参数的使用。\n* 使用该插件时请保证Content-Type为 application/x-www-form-urlencoded、 multipart/form-data 或 application/json。\n\n# 目录\n- [编译教程](#编译教程 \"编译教程\")\n- [安装教程](#安装教程 \"安装教程\")\n- [使用教程](#使用教程 \"使用教程\")\n- [更新日志](#更新日志 \"更新日志\")\n\n# 编译教程\n\n#### 环境要求\n* 系统：基于 Linux 内核（2.6.23+）的系统，CentOS、RedHat 等均可；\n\n* golang版本号：12.x及其以上\n\n* 环境变量设置：\n\t* GO111MODULE：on\n\t\n\t* GOPROXY：https://goproxy.io\n\n\n#### 编译步骤\n\n1.clone项目\n\n2.进入项目文件夹，执行**build.sh**\n```\ncd goku-params_transformer \u0026\u0026 chmod +x build.sh \u0026\u0026 ./build.sh\n```\n\n###### 注：build.sh为通用的插件编译脚本，自定义插件时可以拷贝直接使用。\n\n3.执行第2步将会生成文件： **{插件名}.so**\n\n将该文件上传到**节点服务器运行目录**下的**plugin**文件夹，然后在控制台安装插件即可使用。\n\n# 安装教程\n前往 Goku API Gateway 官方网站查看：[插件安装教程](url \"https://help.eolinker.com/#/tutorial/?groupID=c-341\u0026productID=19\")\n\n# 使用教程\n\n#### 配置页面\n\n进入控制台 \u003e\u003e 策略管理 \u003e\u003e 某策略 \u003e\u003e API插件 \u003e\u003e 参数映射插件：\n\n![](http://data.eolinker.com/course/MciueHY274fe71f0b50c5092e3774aeeccc1a1f29ca9a32)\n\n#### 配置参数\n\n| 参数名 | 说明   | \n| ------------ | ------------ |  \n|  paramName | 待映射参数名称 | \n| paramPosition  | 待映射参数所在位置[body/header/query] |\n| proxyParamName  | 目标参数名称 |   \n| proxyParamPosition  | 目标参数所在位置 |  \n| required  | 是否必含，如为true，该参数不存在时会报错 | \n| removeAfterTransformed  | 映射后删除原参数[true/false] | \n| paramConflictSolution  |  参数冲突时的处理方式 [origin/convert/error] |\n\n参数冲突说明：\n参数映射插件配置了参数A转换成参数B，但是直接请求时既传了A，又传了B，此时为参数出现冲突，参数B实际上会接收两个参数值。\n* convert：参数出现冲突时，取映射后的参数，即A\n* origin：参数出现冲突时，取映射前的参数，即B\n* error：请求时报错，\"param_name\"has a conflict.\n\n若paramConflictSolution为空，视为使用默认值convert。\n\n#### 配置示例\n\n```\n{\n    \"params\": [\n        {\n            \"paramName\": \"userName\", \n            \"paramPosition\": \"body\", \n            \"proxyParamName\": \"loginCall\",\n            \"proxyParamPosition\": \"query\",\n             \"paramConflictSolution\":\"convert\",\n            \"required\": true \n        },\n        {\n            \"paramName\": \"password\",\n            \"paramPosition\": \"body\", \n            \"proxyParamName\": \"loginPassword\",\n            \"proxyParamPosition\": \"query\",\n            \"paramConflictSolution\":\"convert\",\n            \"required\": true\n        }\n    ],\n    \"removeAfterTransformed\": true\n}\n```\n\n#### 请求示例\n\n#### 1. required为true[该参数为必填]\n\n* 映射前：\n\n```\ncurl http://goku:6689/{proxy path} \\\n    -d 'userName=\u003cuser_name\u003e'\n```\n* 根据上面的配置示例经过映射后:\n\n```\ncurl http://goku:6689/{proxy path}?loginCall=\u003cuser_name\u003e \\\n    -d 'userName=\u003cuser_name\u003e'\n```\n\n#### 2. Restful格式\n\n如果请求参数是Restful格式，默认直接映射到转发地址的对应参数，此时 **不需要** 使用参数映射插件。\n\n**接口设置示例**\n\n * 网关请求路径：\n\n    ```\n    /test/:user_name/:pwd\n    ```\n  \n * 映射路径:\n\n    ```\n    /login/:user_name/:pwd\n    ```\n    \n**请求示例**：\n\n * 映射前：\n\n    ```\n    /test/user_1/hashed_pwd\n    ```\n\n * 映射后：\n\n    ```\n    /login/user_1/hashed_pwd\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feolinker%2Fgoku-plugin-params_transformer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feolinker%2Fgoku-plugin-params_transformer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feolinker%2Fgoku-plugin-params_transformer/lists"}