{"id":23913421,"url":"https://github.com/shyamz-22/router","last_synced_at":"2025-06-30T20:05:33.121Z","repository":{"id":57632885,"uuid":"147100051","full_name":"shyamz-22/router","owner":"shyamz-22","description":"A lightweight httprouter","archived":false,"fork":false,"pushed_at":"2019-06-01T13:33:19.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-23T18:32:31.591Z","etag":null,"topics":["go","golang","microservices","rest-api","router","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shyamz-22.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-09-02T15:55:39.000Z","updated_at":"2019-06-01T13:33:21.000Z","dependencies_parsed_at":"2022-08-31T13:20:53.247Z","dependency_job_id":null,"html_url":"https://github.com/shyamz-22/router","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shyamz-22/router","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamz-22%2Frouter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamz-22%2Frouter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamz-22%2Frouter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamz-22%2Frouter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shyamz-22","download_url":"https://codeload.github.com/shyamz-22/router/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shyamz-22%2Frouter/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262842921,"owners_count":23373166,"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":["go","golang","microservices","rest-api","router","web"],"created_at":"2025-01-05T09:45:14.582Z","updated_at":"2025-06-30T20:05:32.999Z","avatar_url":"https://github.com/shyamz-22.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTTP ROUTER\n\nA very lean implementation of http router that supports path param parsing, suitable\nfor most REST implementations. Inspired by [httprouter](https://github.com/julienschmidt/httprouter/blob/master/params_go17.go)\n\n## Usage\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\t\"github.com/shyamz-22/router\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc main() {\n\t\n\trtr := router.New()\n\t\n\trtr.Add(\"/ping\", http.MethodGet, func(w http.ResponseWriter, r *http.Request, params router.PathParams) {\n\t\tw.Write([]byte(\"Pong!\"))\n\t})\n\t\n\trtr.Add(\"/pings/:id\", http.MethodGet, func(w http.ResponseWriter, r *http.Request, params router.PathParams) {\n    \tid := params.ByName(\"id\")\t\n    \tresponse := fmt.Sprintf(\"Pong: %s\", id)\n\t\tw.Write([]byte(response))\n    \t})\n\t\n    log.Fatal(http.ListenAndServe(\":8080\", rtr))\n}\n```\n\n## Running tests\n\n```bash\n\u003e go test -v ./...\n\n```\n\n## Running parallel tests\n\n```bash\n\u003e go test -parallel 8 -v ./...\n\n```\n\n\n## Running Benchmarks\n\n```bash\n\u003e go test -run none -bench Benchmark -benchmem -benchtime 3s -memprofile mem.out\n```\n\n## Memory profiling\n\n```bash\n\u003e go test -run none -bench BenchmarkGithub -benchmem -benchtime 20s -memprofile mem.out\n\u003e go tool pprof -alloc_space router.test mem.out\n \n```\n### Output\n\n```\nFile: router.test\nType: alloc_space\nTime: Sep 2, 2018 at 9:32pm (CEST)\nEntering interactive mode (type \"help\" for commands, \"o\" for options)\n(pprof) top\n(pprof) list findRoute\n\n```\n\n## Setup\n\n```bash\n\u003e go get github.com/shyamz-22/router\n\u003e cd $GOPATH/github.com/shyamz-22/router\n\u003e dep ensure -update\n\u003e go test ./...\n```\n\n## What is not supported yet\n\n- Support for http.Handler\n- Behavior for trailing slashes\n- Configurable NotFound and MethodNotAllowed Handlers\n- Panic Handling\n- Regexp validation for path parameters\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyamz-22%2Frouter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshyamz-22%2Frouter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshyamz-22%2Frouter/lists"}