Lion HTTP 路由器 Lion

polaris • 1869 次点击    
这是一个分享于 的项目,其中的信息可能已经有所发展或是发生改变。
Lion 是一个 Go 语言的快速 HTTP 路由器,支持构建可伸缩的模块化的 REST APIs 应用。 ![Lion&#39;s Hello World GIF](http://static.oschina.net/uploads/img/201603/21072501_zP7s.gif) ## 特性 * **上下文敏感**: Lion 使用事实标准 [net/Context](https://golang.org/x/net/context) 用于存储路由参数并在中间件和 HTTP 处理器之间共享,可集成到 2016 Go 1.7 的标准库中. * **模块化**: 可轻松定义自己的模块实现可伸缩的架构 * **REST 友好**: 可定义模块将 HTTP 资源组合在一起. * **零分配**: Lion 不会产生垃圾 示例代码: <pre class="brush:cpp ;toolbar: true; auto-links: false;">package main import (     &#34;fmt&#34;     &#34;net/http&#34;     &#34;github.com/celrenheit/lion&#34;     &#34;golang.org/x/net/context&#34; ) func Home(c context.Context, w http.ResponseWriter, r *http.Request) {     fmt.Fprintf(w, &#34;Home&#34;) } func Hello(c context.Context, w http.ResponseWriter, r *http.Request) {     name := lion.Param(c, &#34;name&#34;)     fmt.Fprintf(w, &#34;Hello &#34;+name) } func main() {     l := lion.Classic()     l.GetFunc(&#34;/&#34;, Home)     l.GetFunc(&#34;/hello/:name&#34;, Hello)     l.Run() }</pre>
授权协议:
MIT
开发语言:
Google Go 查看源码»
操作系统:
跨平台
1869 次点击  ∙  1 赞  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传