{"id":34851200,"url":"https://github.com/researchlab/hybrid","last_synced_at":"2025-12-25T19:18:22.725Z","repository":{"id":57485929,"uuid":"161122063","full_name":"researchlab/hybrid","owner":"researchlab","description":"hybrid is an API framework of mixture RESTFUL API and RPC API ","archived":false,"fork":false,"pushed_at":"2019-10-03T02:00:23.000Z","size":2951,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-20T09:17:23.806Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/researchlab.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}},"created_at":"2018-12-10T05:30:51.000Z","updated_at":"2024-03-18T15:26:40.000Z","dependencies_parsed_at":"2022-09-18T18:03:36.574Z","dependency_job_id":null,"html_url":"https://github.com/researchlab/hybrid","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/researchlab/hybrid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchlab%2Fhybrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchlab%2Fhybrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchlab%2Fhybrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchlab%2Fhybrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/researchlab","download_url":"https://codeload.github.com/researchlab/hybrid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/researchlab%2Fhybrid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28035466,"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","status":"online","status_checked_at":"2025-12-25T02:00:05.988Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-12-25T19:18:05.851Z","updated_at":"2025-12-25T19:18:22.720Z","avatar_url":"https://github.com/researchlab.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hybrid [![GitHub release](https://img.shields.io/github/release/researchlab/hybrid.svg)](https://github.com/researchlab/hybrid/releases) [![Go Report Card](https://goreportcard.com/badge/github.com/researchlab/hybrid)](https://goreportcard.com/report/github.com/researchlab/hybrid) [![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](http://godoc.org/github.com/researchlab/hybrid) [![LICENSE](https://img.shields.io/github/license/researchlab/hybrid.svg)](https://github.com/researchlab/hybrid/blob/master/LICENSE)\n\n- hybrid is an API framework of mixture RESTFUL API and RPC API \n\n## feature \n- Friendly support RESTFUL API Style\n- Flexible support RPC API Style\n\n## Example \n\n- register modules to the global container [stu](https://github.com/researchlab/hybrid/tree/master/examples/basic)\n\n```\nfunc main() {\n\tstopSigs := make(chan os.Signal, 1)\n\tsignal.Notify(stopSigs, syscall.SIGINT, syscall.SIGTERM)\n\tcontainer := brick.NewContainer()\n\tcontainer.Add(\u0026brick.JSONConfigService{}, \"config\", brick.FactoryFunc(func() interface{} {\n\t\treturn brick.NewJSONConfigService(configPath)\n\t}))\n\tcontainer.Add(\u0026model.Models{}, \"Models\", nil)\n\tcontainer.Add(\u0026mysql.Service{}, \"DB\", nil)\n\tcontainer.Add(\u0026router.HTTPService{}, \"HttpService\", nil)\n\tcontainer.Add(\u0026rest.Controller{}, \"RestController\", nil)\n\tcontainer.Add(\u0026stu.Service{}, \"StuService\", nil)\n\tcontainer.Build()\n\tdefer container.Dispose()\n\tselect {\n\tcase \u003c-stopSigs:\n\t\tlog.Println(\"service has been stoped.\")\n\t}\n}\n```\n\n- router support \n\n```\nr.Route(\"/api/v1/:class\", func(r chi.Router) {\n\t\tr.Get(\"/\", p.Controller.List)\n\t\tr.Post(\"/\", p.Controller.Create)\n\t\tr.Put(\"/\", p.Controller.Update)\n\t\tr.Route(\"/:id\", func(r chi.Router) {\n\t\t\tr.Get(\"/\", p.Controller.Get)\n\t\t\tr.Delete(\"/\", p.Controller.Remove)\n\t\t\tr.Post(\"/\", p.Controller.InvokeServiceFunc())\n\t\t})\n\t})\n```\n\n## Resourcese CURD \n\n### RESTFUL API Style Support \n\n- HTTP POST  / Create resourcese\n```\n➜  ~ curl -XPOST -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/Stu -d'{\"name\":\"mike\",\"address\":\"shanghai.china.002\", \"sex\":\"male\"}'\n{\"ID\":1,\"CreatedAt\":\"2019-03-28T10:20:06.015921+08:00\",\"UpdatedAt\":\"2019-03-28T10:20:06.015921+08:00\",\"DeletedAt\":null,\"Name\":\"mike\",\"Address\":\"shanghai.china.002\",\"Sex\":\"male\"} \n```\n\n- HTTP PUT / Update resourcese\n```\n➜  ~ curl -XPUT -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/Stu -d'{\"ID\":1,\"CreatedAt\":\"2019-03-28T10:20:06+08:00\",\"UpdatedAt\":\"2019-03-28T10:20:06+08:00\",\"DeletedAt\":null,\"Name\":\"mike\",\"Address\":\"shanghai.china.001\",\"Sex\":\"male\"}'\n{\"ID\":1,\"CreatedAt\":\"2019-03-28T10:20:06+08:00\",\"UpdatedAt\":\"2019-03-28T10:35:43.756395+08:00\",\"DeletedAt\":null,\"Name\":\"mike\",\"Address\":\"shanghai.china.001\",\"Sex\":\"male\"}\n```\n\n- HTTP GET / Get One \n```\n➜  ~ curl -XGET -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/Stu/1\n{\"ID\":1,\"CreatedAt\":\"2019-03-28T10:20:06+08:00\",\"UpdatedAt\":\"2019-03-28T10:35:44+08:00\",\"DeletedAt\":null,\"Name\":\"mike\",\"Address\":\"shanghai.china.001\",\"Sex\":\"male\"}\n```\n\n- HTTP GET / Get All\n```\n➜  ~ curl -XGET -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/Stu\n{\"data\":[{\"ID\":1,\"CreatedAt\":\"2019-03-28T10:20:06+08:00\",\"UpdatedAt\":\"2019-03-28T10:35:44+08:00\",\"DeletedAt\":null,\"Name\":\"mike\",\"Address\":\"shanghai.china.001\",\"Sex\":\"male\"}],\"page\":0,\"pageCount\":1,\"pageSize\":10}\n```\n\n- HTTP GET / Get With Where \n```\n➜  ~ curl -XGET -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/Stu\\?where\\=ID\\=\\?%20and%20Name\\=\\?\\\u0026values\\=1,mike\\\u0026pageSize\\=20\n{\"data\":[{\"ID\":1,\"CreatedAt\":\"2019-03-28T10:20:06+08:00\",\"UpdatedAt\":\"2019-03-28T10:35:44+08:00\",\"DeletedAt\":null,\"Name\":\"mike\",\"Address\":\"shanghai.china.001\",\"Sex\":\"male\"}],\"page\":0,\"pageCount\":1,\"pageSize\":20}\n```\n\n- HTTP DELETE / DELETE resourcese\n```\n➜  ~ curl -XDELETE -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/Stu/1\n```\n\n### RPC API Style Support \n\n- request StuService/SayHi Method \n```\n➜  ~ curl -XPOST -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/StuService/SayHi -d'[\"mike\"]'\n[\"Hi, Mr.mike.\\n\",null]\n\n➜  ~ curl -XPOST -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/StuService/SayHi -d'[\"alex\"]'\n[\"Hi, Mrs.alex.\\n\",null]\n\n➜  ~ curl -XPOST -H \"Content-Type: application/json\" http://127.0.0.1:9999/api/v1/StuService/SayHi -d'[\"mike\"]'\n[\"no one named mike found.\",null]\n```\n\n- RPC API Paybody DESC \n  - support array paybody and must Keep in the same order as the function parameters.\n\t- example. func(id uint, name string), must request with POST Protocol AND postBody like [10, \"name\"].\n\n\n## License\n\nhybrid is under Apache v2 License. See the [LICENSE](https://github.com/henrylee2cn/teleport/raw/v5/LICENSE) file for the full license text\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresearchlab%2Fhybrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fresearchlab%2Fhybrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fresearchlab%2Fhybrid/lists"}