cloud-go/gin/1-try/main.go
2022-06-20 09:02:40 +08:00

20 lines
407 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import "github.com/gin-gonic/gin"
func main() {
// 创建一个默认的路由引擎
r := gin.Default()
// GET请求方式
r.GET("/", func(context *gin.Context) {
// c.JSON返回JSON格式的数据
context.JSON(200, gin.H{
"status": "1",
"message": "请求成功",
"data": "Hello333",
})
})
// 启动HTTP服务默认在0.0.0.0:8080启动服务
r.Run()
}