{"id":13616517,"url":"https://github.com/yoyofx/yoyogo","last_synced_at":"2026-01-14T13:27:36.257Z","repository":{"id":39406640,"uuid":"204656174","full_name":"yoyofx/yoyogo","owner":"yoyofx","description":"🦄🌈 YoyoGo is a simple, light and fast , dependency injection based micro-service framework written in Go. Support Nacos ,Consoul ,Etcd ,Eureka ,kubernetes.","archived":false,"fork":false,"pushed_at":"2024-04-19T12:46:06.000Z","size":8711,"stargazers_count":585,"open_issues_count":10,"forks_count":43,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-11-15T00:59:02.004Z","etag":null,"topics":["consul","consul-agent","containers","dependency-injection","eureka","go","grpc","ioc","kubernetes","microservices","middleware","mvc","nacos","web"],"latest_commit_sha":null,"homepage":"http://dev.yoyogo.run","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yoyofx.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}},"created_at":"2019-08-27T08:26:22.000Z","updated_at":"2024-11-03T01:18:44.000Z","dependencies_parsed_at":"2024-04-19T14:05:51.003Z","dependency_job_id":null,"html_url":"https://github.com/yoyofx/yoyogo","commit_stats":{"total_commits":610,"total_committers":10,"mean_commits":61.0,"dds":0.6180327868852459,"last_synced_commit":"f30952a460f0fb05cbed3000ec07622bd34840a1"},"previous_names":["maxzhang1985/yoyogo"],"tags_count":61,"template":false,"template_full_name":null,"purl":"pkg:github/yoyofx/yoyogo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyofx%2Fyoyogo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyofx%2Fyoyogo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyofx%2Fyoyogo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyofx%2Fyoyogo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoyofx","download_url":"https://codeload.github.com/yoyofx/yoyogo/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoyofx%2Fyoyogo/sbom","scorecard":{"id":630176,"data":{"date":"2025-07-07","repo":{"name":"github.com/yoyofx/yoyogo","commit":"6924b33525451f653c7a08741d5a1e25ce9eed7d"},"scorecard":{"version":"v5.2.1-18-gbb9c347d","commit":"bb9c347dff6349d986baab6578a46d68a5524c62"},"score":2.7,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/4 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/Release.yml:1","Warn: no topLevel permission defined: .github/workflows/go.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":2,"reason":"dependency not pinned by hash detected -- score normalized to 2","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:43: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:54: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:64: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:74: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:85: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:95: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:104: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:114: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/Release.yml:124: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/Release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/go.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/go.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/go.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/go.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/yoyofx/yoyogo/go.yml/master?enable=pin","Warn: containerImage not pinned by hash: examples/simpleweb/Dockerfile:1","Warn: containerImage not pinned by hash: examples/simpleweb/Dockerfile:27: pin your Docker image by updating alpine to alpine@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715","Warn: containerImage not pinned by hash: examples/simpleweb/Dockerfile_NoCompile:1: pin your Docker image by updating alpine to alpine@sha256:8a1f59ffb675680d47db6337b49d22281a139e9d709335b492be023728e11715","Warn: downloadThenRun not pinned by hash: .github/workflows/Release.yml:35","Warn: downloadThenRun not pinned by hash: .github/workflows/go.yml:23","Info:   0 out of  13 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned","Info:   0 out of   3 containerImage dependencies pinned","Info:   3 out of   3 goCommand dependencies pinned","Info:   0 out of   2 downloadThenRun dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":1,"reason":"9 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2024-2687 / GHSA-4v7x-pqxf-cx7m","Warn: Project is vulnerable to: GO-2024-3333","Warn: Project is vulnerable to: GO-2025-3503 / GHSA-qxp5-gwg8-xv66","Warn: Project is vulnerable to: GO-2025-3595 / GHSA-vvgc-356p-c3xw","Warn: Project is vulnerable to: GO-2024-2611 / GHSA-8r3f-844c-mc37","Warn: Project is vulnerable to: GO-2024-2937 / GHSA-9phm-fm57-rhg8","Warn: Project is vulnerable to: GO-2025-3488"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/bb9c347dff6349d986baab6578a46d68a5524c62/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T07:40:54.281Z","repository_id":39406640,"created_at":"2025-08-21T07:40:54.281Z","updated_at":"2025-08-21T07:40:54.281Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28421188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T10:47:48.104Z","status":"ssl_error","status_checked_at":"2026-01-14T10:46:19.031Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["consul","consul-agent","containers","dependency-injection","eureka","go","grpc","ioc","kubernetes","microservices","middleware","mvc","nacos","web"],"created_at":"2024-08-01T20:01:29.644Z","updated_at":"2026-01-14T13:27:36.237Z","avatar_url":"https://github.com/yoyofx.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"\u003cimg src=\"https://mnur-prod-public.oss-cn-beijing.aliyuncs.com/0/tech/yoyogo.png\" width = \"380px\" height = \"120px\" alt=\"\" align=center /\u003e[中文](https://github.com/yoyofx/yoyogo/blob/master/README.md)  / [English](https://github.com/yoyofx/yoyogo/blob/master/README_En.md)\n\nYoyoGo 简单、轻量、快速、基于依赖注入的微服务框架\n\n* 文档： https://dev.yoyogo.run\n\n![Release](https://img.shields.io/github/v/tag/yoyofx/yoyogo.svg?color=24B898\u0026label=release\u0026logo=github\u0026sort=semver)\n![Go](https://github.com/yoyofx/yoyogo/workflows/Go/badge.svg)\n![GoVersion](https://img.shields.io/github/go-mod/go-version/yoyofx/yoyogo)\n[![Report](https://goreportcard.com/badge/github.com/yoyofx/yoyogo)](https://goreportcard.com/report/github.com/yoyofx/yoyogo)\n[![Documentation](https://img.shields.io/badge/godoc-reference-blue.svg?color=24B898\u0026logo=go\u0026logoColor=ffffff)](https://godoc.org/github.com/yoyofx/yoyogo)\n![Contributors](https://img.shields.io/github/contributors/yoyofx/yoyogo.svg)\n[![License](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)\n\n# YoyoGo 特色\n- 漂亮又快速的路由器 \u0026 MVC 模式 .\n- 丰富的中间件支持 (handler func \u0026 custom middleware) .\n- 微服务框架抽象了分层，在一个框架体系兼容各种server实现，如 rest,grpc等 .\n- 充分运用依赖注入DI，管理运行时生命周期，为框架提供了强大的扩展性 .\n- 功能强大的微服务集成能力 (Nacos, Eureka, Consul, ETCD) .\n- 受到许多出色的 Go Web 框架的启发，并实现了多种 server : **fasthttp** 和 **net.http** 和 **grpc** .\n\n![framework desgin](https://mnur-prod-public.oss-cn-beijing.aliyuncs.com/0/tech/framework-desgin.jpg)\n\nQQ交流群： [780385870](https://qm.qq.com/cgi-bin/qm/qr?k=xP5ZSGZaLLgJIjK0P89gen8V-p5b1cHg\u0026jump_from=webapi) (Go浪文学院) , 在这里感谢**贾国锦**帮忙设计的logo很漂亮。\n\n也可以加入我的公众号，通过公众号入群菜单进入微信群，主要还是在微信上活动啦。\n\n\u003ca href=\"https://sourcerer.io/yoyofx\"\u003e\u003cimg src=\"https://mnur-prod-public.oss-cn-beijing.aliyuncs.com/0/tech/20201209184239.png\" width = \"180px\" height = \"180px\" alt=\"\" align=center /\u003e\u003c/a\u003e\n\n\n# 框架安装\n```bash\ngo get github.com/yoyofx/yoyogo\n```\n# 安装依赖 (由于某些原因国内下载不了依赖)\n##  go version \u003c 1.20\n```bash\nwindow 下在 cmd 中执行：\nset GO111MODULE=on\nset GOPROXY=https://goproxy.cn,direct\nlinux  下执行：\nexport GO111MODULE=on\nexport GOPROXY=https://goproxy.cn,direct\n```\n##  go version \u003e= 1.13\n```\ngo env -w GOPROXY=https://goproxy.cn,direct\n```\n### vendor\n```\ngo mod vendor       // 将依赖包拷贝到项目目录中去\n```\n# 简单的例子\n```golang\npackage main\nimport ...\n\nfunc main() {\n\tWebApplication.CreateDefaultBuilder(func(rb router.IRouterBuilder) {\n        rb.GET(\"/info\",func (ctx *context.HttpContext) {    // 支持Group方式\n            ctx.JSON(200, context.H{\"info\": \"ok\"})\n        })\n    }).Build().Run()       //默认端口号 :8080\n}\n```\n![](https://mnur-prod-public.oss-cn-beijing.aliyuncs.com/0/tech/20201209182340.png)\n\n## 依赖框架模块\n只涉及框架使用或贡献过的库\n```go\ngithub.com/yoyofxteam/dependencyinjection\n\ngithub.com/yoyofxteam/nacos-viper-remote  \n\ngithub.com/yoyofxteam/reflectx\n\ngithub.com/shima-park/agollo\n```\n# 实现进度\n## 标准功能\n* [X] 打印Logo和日志（YoyoGo）\n* [X] 统一程序输入参数和环境变量 (YoyoGo)\n* [X] 简单路由器绑定句柄功能\n* [X] HttpContext 上下文封装(请求，响应)\n* [X] 静态文件端点（静态文件服务器）\n* [X] JSON 序列化结构（Context.H）\n* [X] 获取请求文件并保存\n* [X] 获取请求数据（form-data，x-www-form-urlencoded，Json ，XML，Protobuf 等）\n* [X] Http 请求的绑定模型（Url, From，JSON，XML，Protobuf）\n### 响应渲染功能\n* [X] Render Interface\n* [X] JSON Render\n* [X] JSONP Render\n* [X] Indented Json Render\n* [X] Secure Json Render\n* [X] Ascii Json Render\n* [X] Pure Json Render\n* [X] Binary Data Render\n* [X] TEXT\n* [X] Protobuf\n* [X] MessagePack\n* [X] XML\n* [X] YAML\n* [X] File\n* [X] Image\n* [X] Template\n* [X] Auto formater Render\n\n## 中间件\n* [X] Logger\n* [X] StaticFile\n* [X] Router Middleware\n* [X] CORS\t\n* [X] Binding\n* [X] JWT\n* [X] RequestId And Tracker for SkyWorking\n\n## 路由\n* [x] GET，POST，HEAD，PUT，DELETE 方法支持\n* [x] 路由解析树与表达式支持\n* [x] RouteData路由数据 (/api/:version/) 与 Binding的集成 \n* [x] 路由组功能\n* [x] MVC默认模板功能\n* [X] MVC 自定义路由\n* [x] 路由过滤器 Filter\n\n## MVC\n* [x] 路由请求触发Controller\u0026Action\n* [x] Action方法参数绑定\n* [x] 内部对象的DI化\n* [x] 关键对象的参数传递\n\n## Dependency injection\n* [X] 抽象集成第三方DI框架\n* [X] MVC模式集成\n* [X] 框架级的DI支持功能\n\n## 扩展\n* [X] 配置\n* [X] WebSocket\n* [X] JWT \n* [X] swagger\n* [X] GRpc\t \n* [X] Prometheus \n\n\n# 进阶范例\n\n```golang\npackage main\n\nimport\n...\n\nfunc main() {\n\twebHost := CreateCustomWebHostBuilder().Build()\n\twebHost.Run()\n}\n\n// 自定义HostBuilder并支持 MVC 和 自动参数绑定功能，简单情况也可以直接使用CreateDefaultBuilder 。\nfunc CreateCustomBuilder() *abstractions.HostBuilder {\n\n\tconfiguration := abstractions.NewConfigurationBuilder().\n\t\tAddEnvironment().\n\t\tAddYamlFile(\"config\").Build()\n\n\treturn WebApplication.NewWebHostBuilder().\n\t\tUseConfiguration(configuration).\n\t\tConfigure(func(app *WebApplication.WebApplicationBuilder) {\n\t\t\tapp.UseMiddleware(middlewares.NewCORS())\n\t\t\t//WebApplication.UseMiddleware(middlewares.NewRequestTracker())\n\t\t\tapp.UseStaticAssets()\n\t\t\tapp.UseEndpoints(registerEndpointRouterConfig)\n\t\t\tapp.UseMvc(func(builder *mvc.ControllerBuilder) {\n\t\t\t\t//builder.AddViews(\u0026view.Option{Path: \"./static/templates\"})\n\t\t\t\tbuilder.AddViewsByConfig()\n\t\t\t\tbuilder.AddController(contollers.NewUserController)\n\t\t\t\tbuilder.AddFilter(\"/v1/user/info\", \u0026contollers.TestActionFilter{})\n\t\t\t})\n\t\t}).\n\t\tConfigureServices(func(serviceCollection *dependencyinjection.ServiceCollection) {\n\t\t\tserviceCollection.AddTransientByImplements(models.NewUserAction, new(models.IUserAction))\n\t\t\t//eureka.UseServiceDiscovery(serviceCollection)\n\t\t\t//consul.UseServiceDiscovery(serviceCollection)\n\t\t\tnacos.UseServiceDiscovery(serviceCollection)\n\t\t}).\n\t\tOnApplicationLifeEvent(getApplicationLifeEvent)\n}\n\n//region endpoint 路由绑定函数\nfunc registerEndpoints(rb router.IRouterBuilder) {\n\tEndpoints.UseHealth(rb)\n\tEndpoints.UseViz(rb)\n\tEndpoints.UsePrometheus(rb)\n\tEndpoints.UsePprof(rb)\n\tEndpoints.UseJwt(rb)\n\t\n\t//swagger api document\n\tendpoints.UseSwaggerDoc(rb,\n\t\tswagger.Info{\n\t\t\tTitle:          \"YoyoGO 框架文档演示\",\n\t\t\tVersion:        \"v1.0.0\",\n\t\t\tDescription:    \"框架文档演示swagger文档 v1.0 [ #yoyogo](https://github.com/yoyofx/yoyogo).\",\n\t\t\tTermsOfService: \"https://dev.yoyogo.run\",\n\t\t\tContact: swagger.Contact{\n\t\t\t\tEmail: \"zl.hxd@hotmail.com\",\n\t\t\t\tName:  \"yoyogo\",\n\t\t\t},\n\t\t\tLicense: swagger.License{\n\t\t\t\tName: \"MIT\",\n\t\t\t\tUrl:  \"https://opensource.org/licenses/MIT\",\n\t\t\t},\n\t\t},\n\t\tfunc(openapi *swagger.OpenApi) {\n\t\t\topenapi.AddSecurityBearerAuth()\n\t\t})\n\n\trb.GET(\"/error\", func(ctx *context.HttpContext) {\n\t\tpanic(\"http get error\")\n\t})\n\n\t//POST 请求: /info/:id ?q1=abc\u0026username=123\n\trb.POST(\"/info/:id\", func(ctx *context.HttpContext) {\n\t\tqs_q1 := ctx.Query(\"q1\")\n\t\tpd_name := ctx.Param(\"username\")\n\n\t\tuserInfo := \u0026UserInfo{}\n\n\t\t_ = ctx.Bind(userInfo) // 手动绑定请求对象\n\n\t\tstrResult := fmt.Sprintf(\"Name:%s , Q1:%s , bind: %s\", pd_name, qs_q1, userInfo)\n\n\t\tctx.JSON(200, context.H{\"info\": \"hello world\", \"result\": strResult})\n\t})\n\n\t// 路由组功能实现绑定 GET 请求:  /v1/api/info\n\trb.Group(\"/v1/api\", func(router *router.RouterGroup) {\n\t\trouter.GET(\"/info\", func(ctx *context.HttpContext) {\n\t\t\tctx.JSON(200, context.H{\"info\": \"ok\"})\n\t\t})\n\t})\n\n\t// GET 请求: HttpContext.RequiredServices获取IOC对象\n\trb.GET(\"/ioc\", func(ctx *context.HttpContext) {\n\t\tvar userAction models.IUserAction\n\t\t_ = ctx.RequiredServices.GetService(\u0026userAction)\n\t\tctx.JSON(200, context.H{\"info\": \"ok \" + userAction.Login(\"zhang\")})\n\t})\n}\n\n//endregion\n\n//region 请求对象\ntype UserInfo struct {\n\tUserName string `param:\"username\"`\n\tNumber   string `param:\"q1\"`\n\tId       string `param:\"id\"`\n}\n\n// ----------------------------------------- MVC 定义 ------------------------------------------------------\n\n// 定义Controller\ntype UserController struct {\n\t*mvc.ApiController\n\tuserAction models.IUserAction // IOC 对象参数\n}\n\n// 构造器依赖注入\nfunc NewUserController(userAction models.IUserAction) *UserController {\n\treturn \u0026UserController{userAction: userAction}\n}\n\n// 请求对象的参数化绑定 , 使用 doc属性标注 支持swagger文档\ntype RegisterRequest struct {\n\tmvc.RequestBody `route:\"/api/users/register\" doc:\"用户注册\"`\n\tUserName   string `uri:\"userName\" doc:\"用户名\"`\n\tPassword   string `uri:\"password\" doc:\"密码\"`\n\tTestNumber uint64 `uri:\"num\" doc:\"数字\"`\n}\n\n// Register函数自动绑定参数\nfunc (this *UserController) Register(ctx *context.HttpContext, request *RegiserRequest) actionresult.IActionResult {\n\tresult := mvc.ApiResult{Success: true, Message: \"ok\", Data: request}\n\treturn actionresult.Json{Data: result}\n}\n\n// use userAction interface by ioc  \nfunc (this *UserController) GetInfo() mvc.ApiResult {\n\treturn this.OK(this.userAction.Login(\"zhang\"))\n}\n\n// DocumentResponse custom document response , use doc tag for swagger\ntype DocumentResponse struct {\n\tMessage string        `json:\"message\" doc:\"消息\"`\n\tList    []DocumentDto `json:\"list\" doc:\"文档列表\"`\n\tSuccess bool          `json:\"success\" doc:\"是否成功\"`\n}\n\n// Swagger API 文档支持\nfunc (controller UserController) GetDocumentList(request *struct {\n\tmvc.RequestGET `route:\"/v1/user/doc/list\" doc:\"获取全部文档列表\"`\n}) DocumentResponse {\n\n\treturn DocumentResponse{Message: \"GetDocumentList\", List: []DocumentDto{\n\t\t{Id: 1, Name: \"test1\", Time: time.Now()}, {Id: 2, Name: \"test2\", Time: time.Now()},\n\t\t{Id: 3, Name: \"test3\", Time: time.Now()}, {Id: 4, Name: \"test4\", Time: time.Now()},\n\t\t{Id: 5, Name: \"test5\", Time: time.Now()}, {Id: 6, Name: \"test6\", Time: time.Now()},\n\t}, Success: true}\n}\n\n\n// Web程序的开始与停止事件\nfunc fireApplicationLifeEvent(life *abstractions.ApplicationLife) {\n\tprintDataEvent := func(event abstractions.ApplicationEvent) {\n\t\tfmt.Printf(\"[yoyogo] Topic: %s; Event: %v\\n\", event.Topic, event.Data)\n\t}\n\tfor {\n\t\tselect {\n\t\tcase ev := \u003c-life.ApplicationStarted:\n\t\t\tgo printDataEvent(ev)\n\t\tcase ev := \u003c-life.ApplicationStopped:\n\t\t\tgo printDataEvent(ev)\n\t\t\tbreak\n\t\t}\n\t}\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoyofx%2Fyoyogo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoyofx%2Fyoyogo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoyofx%2Fyoyogo/lists"}