Gin Web Framework Web 框架 Gin Web Framework

xuanbao2015-05-14 16:00:00 • 12885 次点击    
这是一个分享于 2015-05-14 16:00:00 的项目,其中的信息可能已经有所发展或是发生改变。

Gin 是一个用 Go 语言开发的 Web 框架,提供类 Martini 的 API,但是性能更好。因为有了 httprouter 性能提升了 40 倍之多。

Gin console logger

$ cat test.go
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")
}

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.Read More

Latest commit to the master branch on 4-16-2025
Download as zip
授权协议:
MIT
开发语言:
Google Go 查看源码»
操作系统:
跨平台
12885 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传