{"id":13492780,"url":"https://github.com/go-zoo/bone","last_synced_at":"2025-05-15T08:10:36.479Z","repository":{"id":23475362,"uuid":"26840153","full_name":"go-zoo/bone","owner":"go-zoo","description":"Lightning Fast HTTP Multiplexer","archived":false,"fork":false,"pushed_at":"2019-05-06T14:37:24.000Z","size":2518,"stargazers_count":1287,"open_issues_count":3,"forks_count":101,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-04-07T03:13:55.986Z","etag":null,"topics":["go","mux","router"],"latest_commit_sha":null,"homepage":"http://go-zoo.github.io/bone","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/go-zoo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-19T02:16:36.000Z","updated_at":"2025-02-19T18:26:06.000Z","dependencies_parsed_at":"2022-08-22T00:10:12.245Z","dependency_job_id":null,"html_url":"https://github.com/go-zoo/bone","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-zoo%2Fbone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-zoo%2Fbone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-zoo%2Fbone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-zoo%2Fbone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-zoo","download_url":"https://codeload.github.com/go-zoo/bone/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248889854,"owners_count":21178308,"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","mux","router"],"created_at":"2024-07-31T19:01:09.119Z","updated_at":"2025-04-14T13:41:06.956Z","avatar_url":"https://github.com/go-zoo.png","language":"Go","funding_links":[],"categories":["路由","Web框架","Go","Web Frameworks","Multiplexers","Routers"],"sub_categories":["创建http中间件的代码库","路由器","Advanced Console UIs","Routers"],"readme":"bone [![GoDoc](https://godoc.org/github.com/squiidz/bone?status.png)](http://godoc.org/github.com/go-zoo/bone) [![Build Status](https://travis-ci.org/go-zoo/bone.svg)](https://travis-ci.org/go-zoo/bone) [![Go Report Card](https://goreportcard.com/badge/go-zoo/bone)](https://goreportcard.com/report/go-zoo/bone)\n=======\n\n## What is bone ?\n\nBone is a lightweight and lightning fast HTTP Multiplexer for Golang. It support :\n\n- URL Parameters\n- REGEX Parameters\n- Wildcard routes\n- Router Prefix\n- Route params validators\n- Sub Router, `mux.SubRoute()`, support most standard router (bone, gorilla/mux, httpRouter etc...)\n- Http method declaration\n- Support for `http.Handler` and `http.HandlerFunc`\n- Custom NotFound handler\n- Respect the Go standard `http.Handler` interface\n\n![alt tag](https://c2.staticflickr.com/2/1070/540747396_5542b42cca_z.jpg)\n\n## Speed\n\n```\n- BenchmarkBoneMux        10000000               118 ns/op\n- BenchmarkZeusMux          100000               144 ns/op\n- BenchmarkHttpRouterMux  10000000               134 ns/op\n- BenchmarkNetHttpMux      3000000               580 ns/op\n- BenchmarkGorillaMux       300000              3333 ns/op\n- BenchmarkGorillaPatMux   1000000              1889 ns/op\n```\n\n These tests are just for fun, all these routers are great and efficient.\n Bone isn't the fastest router for every job.\n\n## Example\n\n``` go\n\npackage main\n\nimport(\n  \"net/http\"\n\n  \"github.com/go-zoo/bone\"\n)\n\nfunc main () {\n  mux := bone.New()\n\n  mux.RegisterValidatorFunc(\"isNum\", func(s string) bool {\n    if _, err := strconv.Atoi(s); err == nil {\n      return true\n    }\n    return false\n  })\n\n  // mux.Get, Post, etc ... takes http.Handler\n  // validator for route parameter\n  mux.Get(\"/home/:id|isNum\", http.HandlerFunc(HomeHandler))\n  // multiple parameter\n  mux.Get(\"/profil/:id/:var\", http.HandlerFunc(ProfilHandler))\n  mux.Post(\"/data\", http.HandlerFunc(DataHandler))\n\n  // Support REGEX Route params\n  mux.Get(\"/index/#id^[0-9]$\", http.HandlerFunc(IndexHandler))\n\n  // Handle take http.Handler\n  mux.Handle(\"/\", http.HandlerFunc(RootHandler))\n\n  // GetFunc, PostFunc etc ... takes http.HandlerFunc\n  mux.GetFunc(\"/test\", Handler)\n\n  http.ListenAndServe(\":8080\", mux)\n}\n\nfunc Handler(rw http.ResponseWriter, req *http.Request) {\n  // Get the value of the \"id\" parameters.\n  val := bone.GetValue(req, \"id\")\n\n  rw.Write([]byte(val))\n}\n\n```\n\n## Blog Posts\n- http://www.peterbe.com/plog/my-favorite-go-multiplexer\n- https://harshladha.xyz/my-first-library-in-go-language-hasty-791b8e2b9e69\n\n## Libs\n- Errors dump for Go : [Trash](https://github.com/go-zoo/trash)\n- Middleware Chaining module : [Claw](https://github.com/go-zoo/claw)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-zoo%2Fbone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-zoo%2Fbone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-zoo%2Fbone/lists"}