httprouter源码

1 源码解读

httprouter是一个golang实现的路由组件。httprouter使用一个前缀树(也叫基数树,压缩前缀树)来维护映射的父子关系,通过前缀树快速路由。同时其里面的Router结构体实现了golang的net.http.server的Handler接口下的ServeHTTP方法,可以作为httpHandle发布。golang以性能出名的gin使用的也就是httprouter来做路由处理。

https://learnku.com/articles/27591

2 树的原理

https://cloud.tencent.com/developer/article/1597128

前缀树的初始化

https://www.infoq.cn/article/8tg1alapeyfcakf6zwgh

原文地址:https://www.cnblogs.com/xxswkl/p/14121064.html