cedar-router基于前缀树算法的 golang router
cedar,轻量级 Golang 路由器,基于前缀树算法。
cedar.NewRouter().Get(prefix,http.HandlerFunc,http.Handler)
推荐组件
更新
现在支持了模糊路由匹配
r.Get("/index/:id",func(w http.ResponseWriter, r *http.Request){
fmt.Println(r.URL.Fragment) // <- use this ,get the `id`
},nil)
全局方法
r.GlobalFunc("test", func(r *http.Request) error {
fmt.Println("123213")
return nil
})
支持常见的method
r := cedar.NewRouter()
r.Get("/",http.HandlerFunc(),nil)
r.Post("/",http.HandlerFunc(),nil)
r.Put("/",http.HandlerFunc(),nil)
r.Delete("/",http.HandlerFunc(),nil)
handFunc和Handler在同一路径下我建议只填写一个 . 测试通过websocket ,静态文件路由需要改写ServerHTTP方法.我默认在当前路径下 static/
同一路由下 不同Method ,会覆盖前面的的HandlerFunc和Handler
新版本修复了该问题
群组路由
r := cedar.NewRouter()
r.Group("/a",func (group *cedar.Groups){
group.Get("/b",http.HandlerFunc(),nil)
group.Group("/c",func(groups *cedar.Groups) {
group.Get("/d",http.HandlerFunc(),nil)
})
})
同时也支持RestFul风格
r := cedar.NewRestRouter(cedar.RestConfig{
EntryPath: "blog",
ApiName: "api",
Pattern: ".",
})
r.Get("user", func(writer http.ResponseWriter, request *http.Request) {
r.Template(writer, "/index")
}, nil)
//localhost/blog?api=user
通过 localhost/blog?api=user 获得访问.
软件稳定运行在服务器
评论
wgf基于Golang的框架
文档(Documentation)中文EnglishWgf是什么?Hello,wgf是基于Golang的的编程框架。目标为提供一个尽可能统一的编程环境,提高工作效率。目前,wgf已完成对http、cl
wgf基于Golang的框架
0
rotab基于 goframe 的 golang 博客
rotab 是基于goframe的golang博客,功能模仿wordpress,没有wp强大,关键是golang语言决定的。功能完整的一个博客系统,支持标签分类评论评论审核评论无线嵌套主题等为了开发方
rotab基于 goframe 的 golang 博客
0
mlog-club基于 Golang 的社区系统
mlog-club,一个基于Golang的社区系统。功能机器人搜集公众号文章用户登录、注册,支持Github账号登录用户发表文章、文章评论论坛(发帖、回帖)站内消息文章收藏、帖子收藏相关链接项目地址:
mlog-club基于 Golang 的社区系统
0
GCache基于 Golang 的缓存库
为Golang打造的缓存库。它支持可预期的Cache,LFU,LRU和ARC。功能支持可预见的Cache,LFU,LRU和ARC。Goroutine安全支持驱逐,清除和添加条目的事件处理程序。(可选)
GCache基于 Golang 的缓存库
0