Web 框架:Gin Web Framework
Gin 是一個用 Go 語言開發的 Web 框架,提供類 Martini 的 API,但是性能更好。因為有了 httprouter 性能提升了 40 倍之多。 你如需要一個高性能,高開發效率的框架,那么Gin剛好適合你。
$ 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") }
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!