{"id":15272388,"url":"https://github.com/serkodev/routegen","last_synced_at":"2025-06-20T21:35:57.226Z","repository":{"id":46703508,"uuid":"439318668","full_name":"serkodev/routegen","owner":"serkodev","description":"File-system based route generator for Go. Compatible with any web frameworks.","archived":false,"fork":false,"pushed_at":"2022-07-25T11:08:12.000Z","size":113,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-13T11:15:55.509Z","etag":null,"topics":["echo","file-system-based","generator","gin","go","go-generate","middleware","router"],"latest_commit_sha":null,"homepage":"","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/serkodev.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":"2021-12-17T12:03:47.000Z","updated_at":"2025-05-28T04:26:44.000Z","dependencies_parsed_at":"2022-09-14T22:52:12.190Z","dependency_job_id":null,"html_url":"https://github.com/serkodev/routegen","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/serkodev/routegen","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkodev%2Froutegen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkodev%2Froutegen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkodev%2Froutegen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkodev%2Froutegen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/serkodev","download_url":"https://codeload.github.com/serkodev/routegen/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/serkodev%2Froutegen/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261020838,"owners_count":23098229,"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":["echo","file-system-based","generator","gin","go","go-generate","middleware","router"],"created_at":"2024-09-30T09:05:49.845Z","updated_at":"2025-06-20T21:35:52.211Z","avatar_url":"https://github.com/serkodev.png","language":"Go","readme":"# routegen\n\nFile-system based route generator for Go. Compatible with any web frameworks.\n\n\u003e **Note**  \n\u003e This project is in beta, it may contain bugs and have not being tested at all. Use under your own risk, but feel free to test, make pull request and improve this project.\n\n## Features\n\n- [x] Generate routes from file-system\n- [x] All web frameworks compatible ([customizable](./internal/routegen/engineconfig), default supports [Gin](https://github.com/gin-gonic/gin) \u0026 [echo](https://github.com/labstack/echo))\n- [x] Support middleware\n- [x] Support route with wildcard `/foo/*`\n- [x] Support route with named parameter `/foo/:id`\n- [x] Support route with alias\n\n## Install\n\n```\ngo install github.com/serkodev/routegen/cmd/routegen@latest\n```\n\n## Guides\n\n- [Tutorial](#how-it-works)\n- [Work with all web frameworks](./internal/routegen/engineconfig)\n- [Wildcard \u0026 named parameter](./internal/routegen/testdata/wildcard)\n- [Middleware](./internal/routegen/testdata/middleware)\n- [Sub-route](./internal/routegen/testdata/subroute): Create routes with public type\n- [Route alias](./internal/routegen/testdata/alias): Customize sub-route name\n\n## How it works?\n\n`routegen` will scan your go project folders and generate routes when detects special function name (`GET`, `POST`, etc) in your package. It will use the relative file path as the route path, you may also modify the route name by `alias` and use wildcard or named parameter. The method of code injection refers to [wire](https://github.com/google/wire).\n\nHere we will use [Gin](https://github.com/gin-gonic/gin) as a test example. Create the folder strcuture as below\n\n```\n📁\n|-📁foo\n| |-handle.go\n| |-📁bar\n| | |-handle.go\n|-main.go\n|-go.mod\n```\n\nCreate `./main.go`\n\n```go\n//go:build routegeninject\n\npackage main\n\nimport (\n\t\"github.com/gin-gonic/gin\"\n\t\"github.com/serkodev/routegen\"\n)\n\nfunc Build(g *gin.Engine) {\n    // important! placeholder for routes output\n\troutegen.Build(g)\n}\n\nfunc main() {\n\tg := gin.Default()\n\tBuild(g)\n\tg.Run()\n}\n```\n\nCreate `./foo/handle.go`\n\n```go\npackage foo\n\nimport \"github.com/gin-gonic/gin\"\n\nfunc GET(c *gin.Context) {}\n```\n\nCreate `./foo/bar/handle.go`\n\n```go\npackage bar\n\nimport \"github.com/gin-gonic/gin\"\n\nfunc GET(c *gin.Context) {}\n```\n\nRun generate command at your project root\n```\nroutegen .\n```\n\n`main_gen.go` will be generated. 🎉\n\n```go\n// Code generated by routegen. DO NOT EDIT.\n\n//go:generate go run -mod=mod github.com/serkodev/routegen/cmd/routegen\n//go:build !routegeninject\n// +build !routegeninject\n\npackage main\n\nimport (\n\t\"github.com/gin-gonic/gin\"\n\troutegen_r \"example.com/helloworld/foo\"\n\troutegen_r2 \"example.com/helloworld/foo/bar\"\n)\n\nfunc Build(g *gin.Engine) {\n\tg.GET(\"/foo\", routegen_r.GET)\n\tg.GET(\"/foo/bar\", routegen_r2.GET)\n}\n\nfunc main() {\n\tg := gin.Default()\n\tBuild(g)\n\tg.Run()\n}\n```\n\n## LICENSE\n\nMIT License\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserkodev%2Froutegen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserkodev%2Froutegen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserkodev%2Froutegen/lists"}