{"id":26455019,"url":"https://github.com/dbarbosadev/supermuxer","last_synced_at":"2025-03-18T20:29:41.429Z","repository":{"id":282626238,"uuid":"949092781","full_name":"DBarbosaDev/supermuxer","owner":"DBarbosaDev","description":"Super useful and dependency-free Go package to configure your HTTP routes using only the standard library. Define routes, middlewares, groups, and subgroups effortlessly!  This package acts like a Swiss Army Knife: It is tiny and compact, providing everything you need in just one file with less than 200 lines of code.","archived":false,"fork":false,"pushed_at":"2025-03-15T21:02:55.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T22:18:30.486Z","etag":null,"topics":["dependency-free","go","go-lib","go-package","go-tool","golang","golang-library","golang-package","golang-tools"],"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/DBarbosaDev.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":"2025-03-15T16:55:57.000Z","updated_at":"2025-03-15T22:17:45.000Z","dependencies_parsed_at":"2025-03-16T01:01:00.437Z","dependency_job_id":null,"html_url":"https://github.com/DBarbosaDev/supermuxer","commit_stats":null,"previous_names":["dbarbosadev/supermuxer"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBarbosaDev%2Fsupermuxer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBarbosaDev%2Fsupermuxer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBarbosaDev%2Fsupermuxer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DBarbosaDev%2Fsupermuxer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DBarbosaDev","download_url":"https://codeload.github.com/DBarbosaDev/supermuxer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244300899,"owners_count":20430835,"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":["dependency-free","go","go-lib","go-package","go-tool","golang","golang-library","golang-package","golang-tools"],"created_at":"2025-03-18T20:29:40.761Z","updated_at":"2025-03-18T20:29:41.414Z","avatar_url":"https://github.com/DBarbosaDev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SuperMuxer\n\nSuper **useful** Go package to configure your HTTP routes using only the **standard library**. Define routes, middlewares, groups, and subgroups effortlessly!\n\nThis package acts like a **Swiss Army Knife**: It is **tiny** and **compact**, providing everything you need in just **one** file with **less than 200 lines of code**.\n\n### SuperMuxer is for you if:\n\n- You want to **declaratively** define your HTTP routes while using **only** the standard library.\n- You want to define **middlewares** for your routes, groups, and subgroups while still relying on the standard library.\n- You **don’t** want to use **third-party libraries** bloated with excessive functionalities that you might never use.\n\n\n### How to Use\n\nSimply **clone** the file into your project or **import** it using the following command:\n\n```shell\ngo get github.com/dbarbosadev/supermuxer@v0.1.1\n```\n\n\n## Functionalities\n\n### Declarative route creation\n\n```go\n\nserverMux := http.NewServeMux()\nsuperRouter := supermuxer.New(serverMux)\n\nsuperRouter.Get(\"/users\", handler).Put(\"/users/{id}\", handler)\nsuperRouter.Post(\"/login\", handler)\n\n```\n\n### Middleware association\n\n```go\n\nserverMux := http.NewServeMux()\nsuperRouter := supermuxer.New(serverMux)\n\nsuperRouter.AddMiddlewares(middleware1, middleware2)\nsuperRouter.Get(\"/users\", handler).Put(\"/users/{id}\", handler)\nsuperRouter.Post(\"/login\", handler)\n\n```\n\n### Groups\nCreate a **group of routes** from a **copy** of the original router **without middlewares**. This allows you to define separate route structures while maintaining the original route path.\n\n```go\n\nserverMux := http.NewServeMux()\nsuperRouter := supermuxer.New(serverMux)\nsuperRouter.AddMiddlewares(middleware1, middleware2)\n\n// Route \"POST /login\" with middleware1 and middleware2\nsuperRouter.Post(\"/login\", handler)\n\n// Creates the users group\nuserRouter := superRouter.Group(\"/users\")\n// Group Route \"GET /users\" without middlewares\nuserRouter.Get(\"\", handler)\n\nuserRouter.AddMiddlewares(middleware3)\n// Group Route \"Put /users/{id}\" with middleware3\nuserRouter.Put(\"/{id}\", handler)\n\n\n```\n\n### Subgroups\nWorks the **same way** as the **Group** function, **but** the **subgroup reuses** the middlewares from the original router. This makes it easy to maintain middleware consistency across related routes.\n```go\n\nserverMux := http.NewServeMux()\nsuperRouter := supermuxer.New(serverMux)\nsuperRouter.AddMiddlewares(middleware1, middleware2)\n\n// Route \"POST /login\" with middleware1 and middleware2\nsuperRouter.Post(\"/login\", handler)\n\n// Creates the users group\nuserRouter := superRouter.SubGroup(\"/users\")\n// Group Route \"GET /users\" with middlewares1 and middlewares2\nuserRouter.Get(\"\", handler)\n\nuserRouter.AddMiddlewares(middleware3)\n// Group Route \"Put /users/{id}\" with middlewares1, middlewares2 and middlewares3\nuserRouter.Put(\"/{id}\", handler)\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbarbosadev%2Fsupermuxer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbarbosadev%2Fsupermuxer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbarbosadev%2Fsupermuxer/lists"}