Files
GoCode/main.go
2025-11-18 22:43:31 +08:00

25 lines
626 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()
//从服务器请求资源
r.GET("/", func(c *gin.Context) {
c.String(200, "这是一个get请求用于取出资源")
})
r.POST("/add", func(c *gin.Context) {
c.String(200, "这是一个post--主要用于增加数据")
})
r.PUT("/edit", func(c *gin.Context) {
c.String(200, "这是一个put请求 主要用于编辑数据")
})
r.DELETE("/delete", func(c *gin.Context) {
c.String(200, "这是一个delete请求 主要用于删除数据")
})
err := r.Run()
if err != nil {
return
} // listen and serve on 0.0.0.0:8080
}