{"id":25809909,"url":"https://github.com/42lm/muxify","last_synced_at":"2026-06-12T00:31:17.128Z","repository":{"id":276638684,"uuid":"929569643","full_name":"42LM/muxify","owner":"42LM","description":"Tiny go package providing a minimal functionality mux that wraps around the go default http.ServeMux. Simplify and enhance the setup of the go http.ServeMux.","archived":false,"fork":false,"pushed_at":"2025-08-21T05:05:17.000Z","size":85,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-21T07:26:49.621Z","etag":null,"topics":["default-serve-mux","go","multiplexer","multiplexing","mux","mux-router","pkg","serve-mux","std","stdlib"],"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/42LM.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,"zenodo":null}},"created_at":"2025-02-08T21:12:45.000Z","updated_at":"2025-08-21T05:01:13.000Z","dependencies_parsed_at":"2025-12-20T09:03:32.188Z","dependency_job_id":null,"html_url":"https://github.com/42LM/muxify","commit_stats":null,"previous_names":["42lm/xxsmux","42lm/muxify"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/42LM/muxify","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42LM%2Fmuxify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42LM%2Fmuxify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42LM%2Fmuxify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42LM%2Fmuxify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/42LM","download_url":"https://codeload.github.com/42LM/muxify/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/42LM%2Fmuxify/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34224103,"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":["default-serve-mux","go","multiplexer","multiplexing","mux","mux-router","pkg","serve-mux","std","stdlib"],"created_at":"2025-02-27T23:34:21.543Z","updated_at":"2026-06-12T00:31:17.104Z","avatar_url":"https://github.com/42LM.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# muxify\n[![test: windows](https://github.com/42LM/muxify/actions/workflows/test-windows.yaml/badge.svg)](https://github.com/42LM/muxify/actions/workflows/test-windows.yaml)\n[![test: ubuntu/macos](https://github.com/42LM/muxify/actions/workflows/test-ubuntu-macos.yaml/badge.svg)](https://github.com/42LM/muxify/actions/workflows/test-ubuntu-macos.yaml)\n[![codecov](https://codecov.io/gh/42LM/muxify/graph/badge.svg?token=6CIY6SU7MJ)](https://codecov.io/gh/42LM/muxify)\n[![](https://godoc.org/github.com/42LM/muxify?status.svg)](http://godoc.org/github.com/42LM/muxify)\n[![Go Report Card](https://goreportcard.com/badge/github.com/42LM/muxify)](https://goreportcard.com/report/github.com/42LM/muxify)\n\n\u003cimg width=\"100\" alt=\"muxify\" src=\"https://github.com/user-attachments/assets/5b1d6123-55c9-4e3f-81ee-51ffbea3f9d5\" /\u003e\n\u003cbr\u003e\n\u003cbr\u003e\n\n🪄 _**muxify**_ your mux setup in Go! _**muxify**_ is a tiny go package that provides a minimal functionality mux that wraps around the go default [`http.ServeMux`](https://pkg.go.dev/net/http#ServeMux). The `muxify.Mux` simplifies and enhances the setup of the `http.ServeMux`.  \n\nWrap prefixes and middlewares without clutter. Spin up subrouters for clean organization of the request routing map.\n\n---\n\n* [Install](#install)\n* [Example](#example)\n* [Motivation](#motivation)\n\n\u003e More examples can be found in the [wiki](https://github.com/42LM/muxify/wiki/Examples)\n\n---\n\n## Install\n```sh\ngo get github.com/42LM/muxify\n```\n\n## Example\n_**muxify**_ slightly adopts the syntax of [gorilla/mux](https://github.com/gorilla/mux).\nIt uses a common building block to create a router/subrouter for the serve mux builder.\n\nIt all starts with creating the `muxify.ServeMuxBuilder`\n```go\nmux := muxify.NewMux()\n```\n\nSetup the router\n```go\nmux.Handle(\"GET /\", notFoundHandler)\n```\n\nCreate a subrouter from the root router (prefix and middleware are optional)\n```go\nsubMux := mux.Subrouter()\nsubMux.Use(AdminMiddleware, ChorsMiddleware)\nsubMux.Prefix(\"/admin\")\nsubMux.Handle(\"POST /{id}\", createAdminHandler)\nsubMux.HandleFunc(\"DELETE /{id}\", func(w http.ResponseWriter, r *http.Request) { w.Write(\"DELETE\") })\n```\n\nUse it as usual\n```go\ns.ListenAndServe(\":8080\", mux)\n```\n\n\u003e [!TIP]\n\u003e Check out the registered patterns\n\u003e ```go\n\u003e mux.PrintRegisteredPatterns()\n\u003e ```\n\u003e\n\u003e Chaining is also possible\n\u003e ```go\n\u003e subMux := mux.Subrouter().Prefix(\"/v1\").Use(Middleware1, Middleware2)\n\u003e subMux.Handle(\"GET /topic/{id}\", getTopicHandler)\n\u003e ```\n\n## Motivation\nFirst of all this project exists for the sake of actually using the golang http default serve mux \u003c3.\n\nThe motivation for this project derives from the following two problems with the enhanced routing patterns for the `http.ServeMux`:\n\n### 1. Every single handler needs to be wrapped with middleware. This leads to alot of repeating code and moreover to very unreadable code, too. IMHO it already starts to get out of hands when one handler needs to be wrapped with more than four middlewares.\n\n\u003e To give a little bit more context on this topic just take a look at the following code example:\n\u003e ```go\n\u003e mux.Handle(\"/foo\", Middleware1(Middleware2(Middleware3(Middleware4(Middleware5(Middleware6(fooHandler)))))))\n\u003e ```\n\u003e So even for middlewares that maybe every handler should have (e.g. auth) this is pretty cumbersome to wrap every single handler in it.\n\u003e\n\u003e 💡 _**muxify**_ provides a convenient way of wrapping patterns/routes with middleware and subrouters take over these middlewares.\n\n### 2. No subrouter functionality.\n\n\u003e It is not possible to use the `http.StripPrefix` without defining a pattern for the handler, but sometimes i want to just create a new subrouter from whatever router state.\n\u003e```go\n\u003e router.Handle(\"GET /ping\", makePingHandler(endpoints, options))\n\u003e\n\u003e subrouterV1 := http.NewServeMux()\n\u003e subrouterV1.Handle(\"/v1/\", http.StripPrefix(\"/v1\", router))\n\u003e ```\n\u003e Not being able to use a subrouter adds up to the other problem.\n\u003e A subrouter would help wrapping certain patterns/routes with middleware. A subrouter being created from another router/subrouter always inherits the middlewares.\n\u003e\n\u003e 💡 _**muxify**_ enables the possibility of defining subrouters.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F42lm%2Fmuxify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F42lm%2Fmuxify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F42lm%2Fmuxify/lists"}