这是一个分享于 的项目,其中的信息可能已经有所发展或是发生改变。
Gin 是一个用 Go 语言开发的 Web 框架,提供类 Martini 的 API,但是性能更好。因为有了 [httprouter](http://www.oschina.net/p/httprouter) 性能提升了 40 倍之多。

<pre class="brush:shell;toolbar: true; auto-links: false;">$ cat test.go</pre>
<pre class="brush:cpp ;toolbar: true; auto-links: false;">package main
import (
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.GET("/", func(c *gin.Context) {
c.String(http.StatusOK, "hello world")
})
router.GET("/ping", func(c *gin.Context) {
c.String(http.StatusOK, "pong")
})
router.POST("/submit", func(c *gin.Context) {
c.String(http.StatusUnauthorized, "not authorized")
})
router.PUT("/error", func(c *gin.Context) {
c.String(http.StatusInternalServerError, "an error happened :(")
})
router.Run(":8080")
}</pre>
13601 次点击
添加一条新回复
(您需要 后才能回复 没有账号 ?)
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传