You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
336 B
20 lines
336 B
package main
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func main() {
|
|
// 创建一个默认的路由引擎
|
|
r := gin.Default()
|
|
// 配置路由
|
|
f := func(c *gin.Context) {
|
|
c.JSON(200, gin.H{
|
|
"username": "name1",
|
|
"data": "data1",
|
|
})
|
|
}
|
|
r.GET("/", f)
|
|
// 启动 HTTP 服务,默认在 0.0.0.0:8080 启动服务
|
|
r.Run()
|
|
}
|
|
|