{"id":13676591,"url":"https://github.com/kataras/muxie","last_synced_at":"2025-04-07T06:10:22.478Z","repository":{"id":57480960,"uuid":"153058111","full_name":"kataras/muxie","owner":"kataras","description":"Muxie is a modern, fast and light HTTP multiplexer for Go. Fully compatible with the http.Handler interface. Written for everyone.","archived":false,"fork":false,"pushed_at":"2021-11-16T08:55:06.000Z","size":402,"stargazers_count":279,"open_issues_count":5,"forks_count":23,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-31T05:03:37.412Z","etag":null,"topics":["go","golang","high-performance","iris","router","trie"],"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/kataras.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"kataras"}},"created_at":"2018-10-15T05:34:12.000Z","updated_at":"2025-02-11T21:34:17.000Z","dependencies_parsed_at":"2022-09-26T16:30:59.876Z","dependency_job_id":null,"html_url":"https://github.com/kataras/muxie","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Fmuxie","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Fmuxie/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Fmuxie/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kataras%2Fmuxie/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kataras","download_url":"https://codeload.github.com/kataras/muxie/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247601448,"owners_count":20964864,"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","high-performance","iris","router","trie"],"created_at":"2024-08-02T13:00:30.076Z","updated_at":"2025-04-07T06:10:22.461Z","avatar_url":"https://github.com/kataras.png","language":"Go","funding_links":["https://github.com/sponsors/kataras"],"categories":["开源类库","Multiplexers","Open source library","Go"],"sub_categories":["Web 框架","Web Framework"],"readme":"\u003ch1 align=\"center\"\u003eMuxie\u003c/h1\u003e\n\n\u003cdiv align=\"center\"\u003e\n  :steam_locomotive::train::train::train::train::train:\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003cstrong\u003eFast trie implementation designed from scratch specifically for HTTP\u003c/strong\u003e\n\u003c/div\u003e\n\u003cdiv align=\"center\"\u003e\n  A \u003ccode\u003esmall and light\u003c/code\u003e router for creating sturdy backend \u003ca href=\"https://golang.org\" alt=\"Go Programming Language\"\u003eGo\u003c/a\u003e applications. Production-level tested, muxie's capabilities live inside the well-tested \u003ca href=\"https://iris-go.com\"\u003eIris \u003c/a\u003e web framework.\n\u003c/div\u003e\n\n\u003cbr /\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- Release --\u003e\n  \u003ca href=\"https://github.com/kataras/muxie/releases\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/release%20-v1.1.2-0077b3.svg?style=flat-squaree\"\n      alt=\"Release/stability\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Godocs --\u003e\n  \u003ca href=\"https://godoc.org/github.com/kataras/muxie\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/go-docs-teal.svg?style=flat-square\"\n      alt=\"Godocs\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Build Status --\u003e\n  \u003ca href=\"https://travis-ci.org/kataras/muxie\"\u003e\n    \u003cimg src=\"https://img.shields.io/travis/kataras/muxie/master.svg?style=flat-square\"\n      alt=\"Build Status\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Report Card --\u003e\n  \u003ca href=\"https://goreportcard.com/report/github.com/kataras/muxie\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/report%20card-a%2B-ff3333.svg?style=flat-square\"\n      alt=\"Report Card\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Examples --\u003e\n  \u003ca href=\"https://github.com/kataras/muxie/tree/master/_examples\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/learn%20by-examples-yellow.svg?style=flat-square\"\n      alt=\"Example\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Built for Iris --\u003e\n  \u003ca href=\"https://github.com/kataras/iris\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/built%20for-iris-0077b3.svg?style=flat-square\"\n      alt=\"Built for Iris\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003csub\u003eThe little router that could. Built with ❤︎ by\n  \u003ca href=\"https://twitter.com/MakisMaropoulos\"\u003eGerasimos Maropoulos\u003c/a\u003e\n\u003c/div\u003e\n\n[![Benchmark chart between muxie, httprouter, gin, gorilla mux, echo, vestigo and chi](_benchmarks/chart-17-oct-2018.png)](_benchmarks)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fkataras%2Fmuxie.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Fmuxie?ref=badge_shield)\n\n_Last updated on October 17, 2018._ Click [here](_benchmarks/README.md) to read more details.\n\n## Features\n\n- __trie based:__ [performance](_benchmarks/README.md) and useness are first class citizens, Muxie is based on the prefix tree data structure, designed from scratch and built for HTTP, and it is among the fastest outhere, if not the fastest one\n- __grouping:__ group common routes based on their path prefixes\n- __no external dependencies:__ weighing `30kb`, Muxie is a tiny little library without external dependencies\n- __closest wildcard resolution and prefix-based custom 404:__ wildcards, named parameters and static paths can all live and play together nice and fast in the same path prefix or suffix(!)\n- __small api:__ with only 3 main methods for HTTP there's not much to learn\n- __compatibility:__ built to be 100% compatible with the `net/http` standard package\n\n## Technical Features\n\n- [x] Closest Wildcard Resolution and Root wildcard (CWR)[*](_examples/3_root_wildcard_and_custom_404/main.go)\n- [x] Parameterized Dynamic Path (named parameters with `:name` and wildcards with `*name`, can play all together for the same path prefix|suffix)[*](_examples/2_parameterized/main.go)\n- [x] Standard handlers chain (`Pre(handlers).For(mainHandler)` for individual routes and `Mux#Use` for router)[*](_examples/6_middleware/main.go)\n- [x] Register handlers by method(s) (`muxie.Methods()`)[*](_examples/7_by_methods/main.go)\n- [x] Register handlers by filters (`Mux#HandleRequest` and `Mux#AddRequestHandler` for  `muxie.Matcher` and `muxie.RequestHandler`)\n- [x] Handle subdomains with ease (`muxie.Host` Matcher)[*](_examples/9_subdomains_and_matchers)\n- [x] Request Processors (`muxie.Bind` and `muxie.Dispatch`)[*](_examples/8_bind_req_send_resp)\n\nInterested? Want to learn more about this library? Check out our tiny [examples](_examples) and the simple [godocs page](https://godoc.org/github.com/kataras/muxie).\n\n## Installation\n\nThe only requirement is the [Go Programming Language](https://golang.org/dl/)\n\n```sh\n$ go get -u github.com/kataras/muxie\n```\n\n\u003c!-- ## Philosophy\n\nI believe that providing the right tools for the right job represents my best self\nand I really enjoy writing small libraries and even frameworks that can be used and learnt by thousands like me.\nI do it for the past two and a half years and I couldn't be more happy and proud for myself.\n\n[Iris](https://github.com/kataras/iris) is a web backend framework for Go that is well-known in the Go community,\nsome of you hated it due to a \"battle\" between \"competitors\" followed by a single article written almost three years ago but the majority of you really love it so much that you recommend it to your co-workers, use it inside your companies, startups or your client's projects or even write your postgraduate dissertation based on your own experience with Iris. Both categories of fans\ngave me enough reasons to continue and overcome myself day by day.\n\nIt was about the first days of September(2018) that I decided to start working on the next Iris release(version 11) and all job interviews postponed indefinitely.\nIf you have ever seen or hear about Iris, you already know that Iris is one of the fastest and easy-to-use frameworks, this is why it became so famous in so little time after all. \n\nA lot improvements were pushed over a month+ working full-time on Iris.\nI have never seen a router or a framework supports so many patterns as the current Iris' internal router that is exposed by a beautiful API. However, I couldn't release it for the public yet, I felt that something was missing, I believed that I could do its router smarter and even faster(!) and that ate my guts. And then...in early October, after a lot of testing(and drinking) I found the missing part, it was that the routes' parameterized paths, wildcards and statics all-together for the same path prefix cannot play as fast as possible and good as they should, also I realised that the internal router's code was not the best ever written (it was written to be extremely fast and I didn't care about readability so much back then, when I finally made it to work faster than the rest I forgot to \"prettify\" it due to my excitement!)\n\nInitially the `trie.go` and `node.go` were written for the Iris web framework's version 11 as you can understand by now, I believe that programming should be fun and not stressful, especially for new Gophers. So here we are, introducing a new autonomous Go-based mux(router) that it is light, fast and easy to use for all Gophers, not just for Iris users/developers.\n\nThe `kataras/muxie` repository contains the full source code of my trie implementation and the HTTP component(`muxie.NewMux()`) which is fully compatible with the `net/http` package. Users of this package are not limited on HTTP, they can use it to store and search simple key-value data into their programs (`muxie.NewTrie()`).\n\n\n- The trie implementation is easy to read, and if it is not for you please send me a message to explain to you personally\n- The API is simple, just three main methods and the two of them are the well-known `Handle` and `HandleFunc`, identically to the std package's `net/http#ServeMux`\n- Implements a way to store parameters without touching the `*http.Request` and change the standard handler definition by introducing a new type such as a Context or slow the whole HTTP serve process because of it, look the `GetParam` function and the internal `paramsWriter` structure that it is created and used inside the `Mux#ServeHTTP`\n- Besides the HTTP main functionality that this package offers, users should be able to use it for other things as well, the API is exposed as much as you walk through to\n- Supports named parameters and wildcards of course\n- Supports static path segments(parts, nodes) and named parameters and wildcards for the same path prefix without losing a bit of performance, unlike others that by-design they can't even do it\n\nFor the hesitants: There is a [public repository](https://github.com/kataras/trie-examples-to-remember-again) (previously private) that you can follow the whole process of coding and designing until the final result of `kataras/muxie`'s.\n\nAnd... never forget to put some fun in your life ❤︎\n\nYours,\u003cbr /\u003e\nGerasimos Maropoulos ([@MakisMaropoulos](https://twitter.com/MakisMaropoulos)) --\u003e\n\n## License\n\n[MIT](https://tldrlegal.com/license/mit-license)\n\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fkataras%2Fmuxie.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fkataras%2Fmuxie?ref=badge_large)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkataras%2Fmuxie","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkataras%2Fmuxie","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkataras%2Fmuxie/lists"}