{"id":37903155,"url":"https://github.com/yang-zzhong/go-httprouter","last_synced_at":"2026-01-16T17:06:39.404Z","repository":{"id":57543292,"uuid":"126147901","full_name":"yang-zzhong/go-httprouter","owner":"yang-zzhong","description":"go http router","archived":false,"fork":false,"pushed_at":"2020-09-17T07:39:39.000Z","size":44,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-07-27T22:49:10.484Z","etag":null,"topics":["go","golang","http","router"],"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/yang-zzhong.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}},"created_at":"2018-03-21T08:37:31.000Z","updated_at":"2020-09-17T07:39:26.000Z","dependencies_parsed_at":"2022-08-27T19:10:23.068Z","dependency_job_id":null,"html_url":"https://github.com/yang-zzhong/go-httprouter","commit_stats":null,"previous_names":[],"tags_count":5,"template":null,"template_full_name":null,"purl":"pkg:github/yang-zzhong/go-httprouter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yang-zzhong%2Fgo-httprouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yang-zzhong%2Fgo-httprouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yang-zzhong%2Fgo-httprouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yang-zzhong%2Fgo-httprouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yang-zzhong","download_url":"https://codeload.github.com/yang-zzhong/go-httprouter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yang-zzhong%2Fgo-httprouter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28480081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T11:59:17.896Z","status":"ssl_error","status_checked_at":"2026-01-16T11:55:55.838Z","response_time":107,"last_error":"SSL_read: 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":["go","golang","http","router"],"created_at":"2026-01-16T17:06:37.267Z","updated_at":"2026-01-16T17:06:39.389Z","avatar_url":"https://github.com/yang-zzhong.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Go HTTP Router\n\n## Feature\n\n1. Support group and middleware\n2. With a static server that support front end route\n3. Support restful params\n\n```go\nimport (\n    \"log\"\n    \"logic\" // user app provide\n    \"net/http\"\n    hr \"github.com/yang-zzhong/go-httprouter\"\n)\n\nrouter := hr.NewRouter()\n\n//\n// config the try order, here we use the default order\n// the router will first match the api, the pathfile based on docroot, the a configed entry file based on docroot\n//\nrouter.Tries = []string{hr.API, hr.PATHFILE, hr.ENTRYFILE} \n\n// only match api\nrouter.Tries = []string{hr.API}\n\n// config docroot\nrouter.DocRoot = \"/srv/http/test\"\n\n// config api\n\nrouter.Group(\"/api\", []Mw{}, func(router *Router) {\n    router.OnGet(\"/users\", usersList)\n    router.OnGet(\"/users/:user_id\", user)\n    router.OnPost(\"/users\", createUser)\n\n    router.Group(\"\", []Mw{new(logic.Auth)}, func(router *Router) {\n        router.OnPut(\"/users/:user_id\", updateUser)\n    });\n})\n\nrouter.OnGet(\"/hello-world\", hello)\nlog.Fatal(http.ListenAndServe(\":8080\", router))\n\nvar userList HttpHandler = func(w *hr.Response, req *hr.Request) {\n    page, _ := req.FormInt(\"page\")\n    pageSize, _ := req.FormatInt(\"page_size\")\n    w.WithString(logic.UserList(page, pageSize).Json())\n}\n\nvar user HttpHandler = func(w *hr.Response, req *hr.Request) {\n    w.WithString(logic.User(p.Get(\"user_id\")).Json())\n}\n\nvar createUser HttpHandler = func(w *hr.Response, req *hr.Request) {\n    params := map[string]interface{}{\n        \"name\": req.FormValue(\"name\"),\n        \"account\": req.FormValue(\"account\"),\n        \"extra\": req.FormMap(\"extra\"),\n    }\n    if err := logic.CreateUser(params); err != nil {\n        panic(err)\n    }\n    w.WithString(\"创建成功\")\n}\n\nvar createUser HttpHandler = func(w *hr.Response, req *hr.Request) {\n    params := map[string]interface{}{\n        \"name\": req.FormValue(\"name\"),\n        \"account\": req.FormValue(\"account\"),\n        \"extra\": req.FormMap(\"extra\"),\n    }\n    if err := logic.UpdateUser(req.Bag.Get(\"user_id\"), params); err != nil {\n        panic(err)\n    }\n\n    w.WithString(\"更新成功\")\n}\n\nvar hello HttpHandler = func(w *hr.Response, _ *hr.Request) {\n    w.WithString(\"hello world!!!\")\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyang-zzhong%2Fgo-httprouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyang-zzhong%2Fgo-httprouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyang-zzhong%2Fgo-httprouter/lists"}