gin

时间:2022-10-07 17:56:32


安装

go get -u github.com/gin-gonic/gin

 

 

package main

import (
"github.com/gin-gonic/gin"
"log"
)

func main() {

engine := gin.Default()
engine.GET("/hello", func(context *gin.Context) {
log.Println("请求路径", context.FullPath())

context.Writer.Write([]byte("HELLO , GIN\n"))

})

engine.GET("/angdh", func(context *gin.Context) {
log.Println("请求路径", context.FullPath())

context.Writer.WriteString("HELLO , angdh\n")

})

engine.GET("/json", func(context *gin.Context) {
log.Println("请求路径", context.FullPath())

context.JSON(200,map[string]interface{}{
"code":1,
"message":"ok",
})

})

if err := engine.Run(":10889"); err != nil {

log.Fatal(err.Error())
}

}

 

 

 

gin

 

 


 

 

gin

 

 

 


 

 

gin