{"id":20477245,"url":"https://github.com/lockgit/xhttp","last_synced_at":"2025-06-17T03:07:29.188Z","repository":{"id":87536793,"uuid":"562947094","full_name":"LockGit/xhttp","owner":"LockGit","description":"Http schedule flow 🚀","archived":false,"fork":false,"pushed_at":"2022-11-19T05:19:24.000Z","size":2532,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T14:48:43.598Z","etag":null,"topics":["flow","http","schedule","xhttp"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LockGit.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-11-07T15:34:30.000Z","updated_at":"2024-04-09T14:50:31.000Z","dependencies_parsed_at":"2023-05-10T12:31:30.427Z","dependency_job_id":null,"html_url":"https://github.com/LockGit/xhttp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LockGit/xhttp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LockGit%2Fxhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LockGit%2Fxhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LockGit%2Fxhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LockGit%2Fxhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LockGit","download_url":"https://codeload.github.com/LockGit/xhttp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LockGit%2Fxhttp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260281567,"owners_count":22985629,"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":["flow","http","schedule","xhttp"],"created_at":"2024-11-15T15:26:52.492Z","updated_at":"2025-06-17T03:07:29.166Z","avatar_url":"https://github.com/LockGit.png","language":"Go","readme":"### xhttp\n\n### what is xhttp ?\n\nxhttp ---\u003e 将一个或者多个 http api 按照自定义的编排配置方式，进行并行或串行聚合后并将结果返回\n![](./xhttp.png)\n\n场景：\n* 将后端的多个API聚合处理，只暴漏一个API给到前端\n* 自动化测试验证\n* ....\n\n### 配置定义\n\nstorage/demo下的文件夹表示项目名，每个项目下的routes.json为要编排的路由\n\n| 字段                                  | 类型     | 说明                                               |\n|-------------------------------------|--------|--------------------------------------------------|\n| url                                 | string | 匹配url,指定值或/path/:id占位符或/path/some*通配符形式均可        |\n| method                              | string | 当前项目url所支持的http请求                                |\n| execType                            | string | parallel=并行，serial=串行                            |\n| children                            | array  | 待编排的子api                                         |\n| children[x].name                    | string | 子api的别名                                          |\n| children[x].url                     | string | 子api的url                                         |\n| children[x].method                  | string | 子api的请求方式                                        |\n| children[x].params                  | array  | 子api的请求参数                                        |\n| children[x].params[x].name          | string | 子api的请求参数名                                       |\n| children[x].params[x].source        | string | 子api的请求参数取值来源                                    |\n| children[x].params[x].default_value | string | 子api的请求参数默认值                                     |\n| children[x].params[x].required      | string | 子api的请求参数是否必填                                    |\n\n其中取值来源children[x].params[x].source 支持有以下：\n\n| 字段         | 类型     | 说明                                  |\n|------------|--------|-------------------------------------|\n| $.query    | string | 从http query中获取参数                    |\n| $.body     | string | 从http body中获取参数                     |\n| $.header   | string | 从http header中获取参数                   |\n| $.cookie   | string | 从http cookie中获取参数                   |\n| $.someName | string | 从name=someName api结果中获取参数(仅并行聚合时生效) |\n\n### demo\n\n```bash\ngo run main.go\n\ncurl -XPOST  http://127.0.0.1:8888/test?prod=env\u0026from=pc\u0026json=1 -H 'X-Project:hello' \n\nX-Project的值即为项目名,上面curl请求表示当前请求发到那个hello项目\n```\n\n服务接收到请求后，会匹配/test路由，/test下有2个子路由：\n\n* 表示对children中的两个url（name=aaa,name=bbb）进行parallel(并行)聚合操作。\n* 以children解释说明： 两个children中的url都配置了: https://www.baidu.com/sugrec\n* 第2个children的get请求的参数有如下：\n    * prod(从query中取值)\n    * from(从header中取值)\n    * name(从body中取值)\n    * age(从cookie中取值)\n    * other(从$.aaa【前一个name=aaa的api结果中取值】,仅在串行聚合中生效)\n\n```json\n{\n  \"url\": \"/test\",\n  \"method\": \"post\",\n  \"execType\": \"parallel\",\n  \"children\": [\n    {\n      \"name\": \"aaa\",\n      \"url\": \"https://www.baidu.com/sugrec\",\n      \"method\": \"get\",\n      \"params\": [\n        {\n          \"name\": \"prod\",\n          \"source\": \"$.query\",\n          \"default_value\": \"pc_his\",\n          \"required\": true\n        },\n        {\n          \"name\": \"from\",\n          \"source\": \"$.header\",\n          \"default_value\": \"pc\",\n          \"required\": true\n        },\n        {\n          \"name\": \"name\",\n          \"source\": \"$.body\",\n          \"default_value\": \"1\",\n          \"required\": true\n        },\n        {\n          \"name\": \"age\",\n          \"source\": \"$.cookie\",\n          \"default_value\": \"1\",\n          \"required\": true\n        }\n      ],\n      \"timeout\": 3\n    },\n    {\n      \"name\": \"bbb\",\n      \"url\": \"https://www.baidu.com/sugrec\",\n      \"method\": \"get\",\n      \"params\": [\n        {\n          \"name\": \"prod\",\n          \"source\": \"$.query\",\n          \"default_value\": \"pc_his\",\n          \"required\": true\n        },\n        {\n          \"name\": \"from\",\n          \"source\": \"$.query\",\n          \"default_value\": \"pc\",\n          \"required\": true\n        },\n        {\n          \"name\": \"name\",\n          \"source\": \"$.query\",\n          \"default_value\": \"1\",\n          \"required\": true\n        },\n        {\n          \"name\": \"age\",\n          \"source\": \"$.cookie\",\n          \"default_value\": \"1\",\n          \"required\": true\n        },\n        {\n          \"name\": \"other\",\n          \"source\": \"$.aaa\",\n          \"default_value\": \"test\",\n          \"required\": true\n        }\n      ],\n      \"timeout\": 3\n    }\n  ]\n}\n```\n\n```bash\ncurl -XPOST  http://127.0.0.1:8888/demo -H 'X-Project:hello'\n```\n\n```json\n{\n  \"aaa\": \"{\\\"err_no\\\":0,\\\"errmsg\\\":\\\"\\\",\\\"queryid\\\":\\\"0x4a72d4bbf5c4bd\\\"}\",\n  \"bbb\": \"{\\\"err_no\\\":0,\\\"errmsg\\\":\\\"\\\",\\\"queryid\\\":\\\"0x1acd194c0f99b0\\\"}\"\n}\n```\n\n### 注意\n\n* children[x].url 的配置应该是确定的，否则可能会触发ssrf\n* 用go写的速成项目，验证猜想， xhttp 还未经过大量的验证和实践","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flockgit%2Fxhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flockgit%2Fxhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flockgit%2Fxhttp/lists"}