6

gin url树

 3 years ago
source link: https://blog.csdn.net/oqqYuan1234567890/article/details/72599568
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

gin url树

original.png
皿小草 2017-05-21 17:10:06 1087

在看gin源码的时候,发现其组织router的时候,使用到了Radix tree结构,关于Radix tree的介绍,请参考wiki Radix tree,Radix tree是Trie树的存储空间优化版本。方便快速匹配url。

gin路由其实采用了https://github.com/julienschmidt/httprouter 这个项目的路由,gin是一个非常精致的framework,代码量不多,web开发可以参考gin造轮子。毕竟号称最快的go web framework之一,

具体的url树组织文件位于
https://github.com/julienschmidt/httprouter/blob/master/tree.go
花点时间就行,有很多注释。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK