{"id":42049207,"url":"https://github.com/donutloop/mux","last_synced_at":"2026-01-26T06:33:03.058Z","repository":{"id":87159648,"uuid":"74228001","full_name":"donutloop/mux","owner":"donutloop","description":"mux is a lightweight HTTP request router","archived":false,"fork":false,"pushed_at":"2017-07-20T16:30:56.000Z","size":66,"stargazers_count":321,"open_issues_count":2,"forks_count":13,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-08-14T12:16:06.951Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/donutloop.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,"publiccode":null,"codemeta":null}},"created_at":"2016-11-19T18:44:45.000Z","updated_at":"2025-08-13T22:49:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3b6c15e-4823-4449-be27-8934d6bbdb60","html_url":"https://github.com/donutloop/mux","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/donutloop/mux","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donutloop%2Fmux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donutloop%2Fmux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donutloop%2Fmux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donutloop%2Fmux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/donutloop","download_url":"https://codeload.github.com/donutloop/mux/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/donutloop%2Fmux/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28768382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T03:54:34.369Z","status":"ssl_error","status_checked_at":"2026-01-26T03:54:33.031Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2026-01-26T06:33:02.361Z","updated_at":"2026-01-26T06:33:03.053Z","avatar_url":"https://github.com/donutloop.png","language":"Go","readme":"[![Build Status](https://travis-ci.org/donutloop/mux.svg?branch=master)](https://travis-ci.org/donutloop/mux)\n\n# What is mux ?\n\nmux is a lightweight fast HTTP request router (also called multiplexer or just mux for short) for Go 1.7.\n\nThe difference between the default mux of Go's net/http package and this mux is,\nit's supports variables and regex in the routing pattern and matches against the request method. It also scales better.\n\n## Features:\n\n* REGEX URL Matcher\n* Vars URL Matcher\n* GetVars in handler\n* GetQueries in handler\n* URL Matcher\n* Header Matcher\n* Scheme Matcher \n* Custom Matcher\n* Route Validators \n* Http method declaration\n* Support for standard lib http.Handler and http.HandlerFunc\n* Custom NotFound handler\n* Respect the Go standard http.Handler interface\n* Routes are sorted\n* Context support\n\n## Feature request are welcome\n\n## Example (Method GET):\n\n```go\n    package main\n\n    import (\n        \"net/http\"\n        \"fmt\"\n        \"os\"\n\n        \"github.com/donutloop/mux\"\n    )\n\n    func main() {\n        r := mux.Classic()\n\n        //URL: https://localhost:8080/home\n        r.HandleFunc(http.MethodGet, \"/home\", homeHandler)\n        \n        //URL: https://localhost:8080/home-1\n        r.Handle(http.MethodGet, \"/home-1\", http.HandlerFunc(homeHandler))\n        \n        //URL: https://localhost:8080/home-2\n        r.Get(\"/home-2\", homeHandler)\n        \n        //URL: https://localhost:8080/home-3\n        r.RegisterRoute(http.MethodGet, r.NewRoute().Path(\"/home-3\").HandlerFunc(homeHandler))\n        \n        //URL: https://localhost:8080/home-4\n        r.RegisterRoute(http.MethodGet, r.NewRoute().Path(\"/home-4\").Handler(http.HandlerFunc(homeHandler)))\n        \n    \terrorHandler := func(errs []error) {\n            for _ , err := range errs {\n                fmt.Print(err)\n            }\n            if 0 != len(errs) {\n                os.Exit(2)\n            }\n\t    }\n\n        r.ListenAndServe(\":8080\", errorHandler)\n    }\n\n    func homeHandler(rw http.ResponseWriter, req *http.Request) {\n        //...\n        rw.Write([]byte(\"Hello World!\"))\n    }\n```\n\n## Example (Method POST):\n\n```go\n    package main\n\n    import (\n        \"net/http\"\n        \"fmt\"\n        \"os\"\n\n        \"github.com/donutloop/mux\"\n    )\n\n    func main() {\n        r := mux.Classic()\n\n        //URL: https://localhost:8080/user/create\n        r.HandleFunc(http.MethodPost, \"/user/create\", userHandler)\n\n        //URL: https://localhost:8080/user-1/create\n        r.Handle(http.MethodPost, \"/user-1/create\", http.HandlerFunc(userHandler))\n\n        //URL: https://localhost:8080/user-2/create        \n        r.Post(\"/user-2/create\", userHandler)\n\n        //URL: https://localhost:8080/user-3/create\n        r.RegisterRoute(http.MethodPost, r.NewRoute().Path(\"/user-3/create\").HandlerFunc(userHandler))\n\n        //URL: https://localhost:8080/user-4/create        \n        r.RegisterRoute(http.MethodPost, r.NewRoute().Path(\"/user-4/create\").Handler(http.HandlerFunc(userHandler)))\n        \n    \terrorHandler := func(errs []error) {\n            for _ , err := range errs {\n                fmt.Print(err)\n            }\n            if 0 != len(errs) {\n                os.Exit(2)\n            }\n\t    }\n\n        r.ListenAndServe(\":8080\", errorHandler)\n    }\n\n    func userHandler(rw http.ResponseWriter, req *http.Request) {\n        //...\n        rw.Write([]byte(\"Created successfully a new user\"))\n    }\n```\n\n## Example (Method GET \u0026 Scheme Matcher):\n\n```go\n    package main\n\n    import (\n        \"net/http\"\n        \"fmt\"\n        \"os\"\n\n        \"github.com/donutloop/mux\"\n    )\n\n    func main() {\n        r := mux.Classic()\n        \n        //URL: https://localhost:8080/home\n        r.Get(\"/home\", homeHandler).Schemes(\"https\")\n        \n    \terrorHandler := func(errs []error) {\n            for _ , err := range errs {\n                fmt.Print(err)\n            }\n            if 0 != len(errs) {\n                os.Exit(2)\n            }\n\t    }\n\n        r.ListenAndServe(\":8080\", errorHandler)\n    }\n\n    func homeHandler(rw http.ResponseWriter, req *http.Request) {\n        //...\n        rw.Write([]byte(\"Hello world\"))\n    }\n```\n## Example (Method Put \u0026 GetVars):\n\n```go\n    package main\n\n    import (\n        \"net/http\"\n        \"fmt\"\n        \"os\"\n\n        \"github.com/donutloop/mux\"\n    )\n\n    func main() {\n        r := mux.Classic()\n        \n        //URL: http://localhost:8080/user/update/1\n        r.Put(\"/user/update/:number\", userHandler)\n\n    \terrorHandler := func(errs []error) {\n            for _ , err := range errs {\n                fmt.Print(err)\n            }\n            if 0 != len(errs) {\n                os.Exit(2)\n            }\n\t    }\n\n        r.ListenAndServe(\":8080\", errorHandler)\n    }\n\n    func userHandler(rw http.ResponseWriter, req *http.Request) {\n        userId := mux.GetVars(req).Get(\":number\")\n        //...\n        rw.Write([]byte(\"Updated successfully a new user\"))\n    }\n```\n\n## Example (Method GET \u0026 GetQueries):\n\n```go\n    package main\n\n    import (\n        \"net/http\"\n        \"fmt\"\n        \"os\"\n\n        \"github.com/donutloop/mux\"\n    )\n\n    func main() {\n        r := mux.Classic()\n        \n        //URL: http://localhost:8080/users?limit=10\n        r.Get(\"/users\", userHandler)\n\n    \terrorHandler := func(errs []error) {\n            for _ , err := range errs {\n                fmt.Print(err)\n            }\n            if 0 != len(errs) {\n                os.Exit(2)\n            }\n\t    }\n\n        r.ListenAndServe(\":8080\", errorHandler)\n    }\n\n    func userHandler(rw http.ResponseWriter, req *http.Request) {\n        limit := mux.GetQueries(req).Get(\"limit\")[0]\n        //...\n    }\n```\n\n## Example (Method GET \u0026 Regex):\n\n```go\n    package main\n\n    import (\n        \"net/http\"\n        \"fmt\"\n        \"os\"\n\n        \"github.com/donutloop/mux\"\n    )\n\n    func main() {\n        r := mux.Classic()\n        \n        //URL: http://localhost:8080/user/1\n        r.Get(\"/user/#([0-9]){1,}\", userHandler)\n\n    \terrorHandler := func(errs []error) {\n            for _ , err := range errs {\n                fmt.Print(err)\n            }\n            if 0 != len(errs) {\n                os.Exit(2)\n            }\n\t    }\n\n        r.ListenAndServe(\":8080\", errorHandler)\n    }\n\n    func userHandler(rw http.ResponseWriter, req *http.Request) {\n        //...\n    }\n```\n## More documentation comming soon","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonutloop%2Fmux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdonutloop%2Fmux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdonutloop%2Fmux/lists"}