go get github.com/gin-gonic/gin
package main
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.StaticFile("/", "./static")静态文件
// limit form size 8MB,default 32MB
r.MaxMultipartMemory = 8 << 20
r.GET("/hello", func(ctx *gin.Context) {
ctx.String(http.StatusOK, "Hello World")
})
// restful api
r.GET("/hello/:name", func(ctx *gin.Context) {
name := ctx.Param("name")
ctx.String(http.StatusOK, "hello "+name)
})
}