{"id":19544130,"url":"https://github.com/luooojunnn/gono","last_synced_at":"2026-06-11T13:31:02.757Z","repository":{"id":126808998,"uuid":"232552353","full_name":"Luooojunnn/gono","owner":"Luooojunnn","description":"前端方式编写 Go web服务","archived":false,"fork":false,"pushed_at":"2020-01-10T08:16:20.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-26T05:41:31.560Z","etag":null,"topics":["golang","web"],"latest_commit_sha":null,"homepage":null,"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/Luooojunnn.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":"2020-01-08T11:53:30.000Z","updated_at":"2020-01-14T01:01:20.000Z","dependencies_parsed_at":"2023-06-18T04:03:03.463Z","dependency_job_id":null,"html_url":"https://github.com/Luooojunnn/gono","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Luooojunnn/gono","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luooojunnn%2Fgono","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luooojunnn%2Fgono/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luooojunnn%2Fgono/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luooojunnn%2Fgono/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Luooojunnn","download_url":"https://codeload.github.com/Luooojunnn/gono/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Luooojunnn%2Fgono/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34201839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-11T02:00:06.485Z","response_time":57,"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":["golang","web"],"created_at":"2024-11-11T03:24:44.979Z","updated_at":"2026-06-11T13:31:02.735Z","avatar_url":"https://github.com/Luooojunnn.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gono\n\n使用更 “前端” 一点的书写方式来写 go web 服务吧！\n\n\n### 用法\n\n**go version 1.11+**\n\n\u003e import \"github.com/Luooojunnn/gono\"\n\ngo run 你的项目的时候，自动在 go.sum 中下载保存 gono 信息啦\n\n---\n\n**1. 启动服务就是那么简单！**\n\n❌\n```golang\npackage main\n\nimport (\n\t\"io\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc main() {\n\t// Hello world, the web server\n\n\thelloHandler := func(w http.ResponseWriter, req *http.Request) {\n\t\tio.WriteString(w, \"Hello, world!\\n\")\n\t}\n\n\thttp.HandleFunc(\"/hello\", helloHandler)\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n✅\n```golang\npackage main\n\nimport (\n\t\"gono\"\n\t_ \"./routes\"\n)\n\n// var conf = structs.InitParams{\n// \tProxy: false,\n// }\n\nfunc main()  {\n\tgn := gono.Init()\n\tgn.Listen(9000)\n}\n```\n\n**2. 请求拦截就是那么简单！**\n\n✅\n\n**GET**\n\n```golang\npackage routes\n\nimport (\n\t\"gono/router\"\n\t\"gono/utils\"\n\t\"fmt\"\n) \n\n// 模拟路由拆分\n\n// get 方法\nfunc init(){\n\trouter.G(\"/\").Then(func(ctx *utils.Ctx) {\n\t\tctx.Body = 112233\n\t\tquery := ctx.Query\n\t\tfor key, val := range query {\n\t\t\tfmt.Println(\"key: \" + key + \", value: \", val)\n\t\t}\n\t}).Then(func(ctx *utils.Ctx)  {\n\t\tfmt.Println(\"你好，世界\")\n\t}).Then(func(ctx *utils.Ctx)  {\n\t\tfmt.Println(\"hello, world\")\n\t})\n}\n```\n**POST**\n\n```golang\npackage routes\n\nimport (\n\t\"gono/utils\"\n\t\"gono/router\"\n\t\"fmt\"\n) \n\n// 模拟路由拆分\n\nfunc init()  {\n\tPostUser()\n}\n// post 方法\nfunc PostUser() {\n\trouter.P(\"/user\").Then(func(ctx *utils.Ctx) {\n\t\tctx.Body = map[string]interface{} {\n\t\t\t\"name\": \"emine\",\n\t\t\t\"age\": 20,\n\t\t}\n\n\t\tquery := ctx.Query\n\t\tfor key, val := range query {\n\t\t\tfmt.Println(\"key: \" + key + \", value: \", val)\n\t\t}\n\n\t\tctx.Extra = \"我是要透传给下一个 then 的信息\"\n\t}).Then(func(ctx *utils.Ctx) {\n\t\tfmt.Println(ctx.Extra)\n\t})\n}\n\n```\n\n**3. 就是那么简单！**\n\n目前来说，Then 里边的回调的入参 ctx 上边仅有：\n \n - Body - 类似 koa ，返回体的内容\n - Query - 请求携带的参数，在此处获取，是一个 map 结构\n - Extra - 额外信息，可以通过它将信息传递给下一个 Then\n\n*请注意：使用链式的 Then ，入参函数会顺序执行，后边的 Then 会覆盖前边的赋值*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluooojunnn%2Fgono","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluooojunnn%2Fgono","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluooojunnn%2Fgono/lists"}