HTTP 多路復用器:Bone
Bone 是一個輕量級、非常快速的 HTTP 多路復用器,支持 URL 變量、HTTP 方法聲明和自定義 NotFound 處理器。
Speed
- BenchmarkBoneMux 10000000 118 ns/op - BenchmarkZeusMux 100000 54813 ns/op - BenchmarkHttpRouterMux 10000000 143 ns/op - BenchmarkNetHttpMux 3000000 548 ns/op - BenchmarkGorillaMux 300000 3333 ns/op - BenchmarkGorillaPatMux 1000000 1889 ns/op
[ These test are just for fun, all these router are great and really efficient. ]
Examplepackage main import( "net/http" "github.com/squiidz/bone" ) func main () { mux := bone.New() // Method takes http.HandlerFunc mux.Get("/home/:id", HomeHandler) mux.Post("/data", DataHandler) // Handle take http.Handler mux.Handle("/", http.HandlerFunc(RootHandler)) http.ListenAndServe(":8080", mux) }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!