We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c392065 commit 6733b03Copy full SHA for 6733b03
gin-web-app/main.go
@@ -6,6 +6,13 @@ import (
6
"github.com/gin-gonic/gin"
7
)
8
9
+// album represents data about a record album.
10
+type userDetail struct {
11
+ ID string `json:"id"`
12
+ Name string `json:"name"`
13
+ Age int `json:"age"`
14
+}
15
+
16
func helloCall(c *gin.Context) {
17
c.JSON(http.StatusOK, gin.H{"message": "Hello, You created a Web App!"})
18
}
@@ -22,6 +29,16 @@ func getUser(c *gin.Context) {
22
29
c.JSON(http.StatusOK, gin.H{"message": "Hello, " + name + "!"})
23
30
24
31
32
+func getUsers(c *gin.Context) {
33
+ var users = []userDetail{
34
+ {ID: "1", Name: "Blue Train", Age: 56},
35
+ {ID: "2", Name: "Akash", Age: 11},
36
+ {ID: "3", Name: "pradip", Age: 56},
37
+ }
38
39
+ c.JSON(http.StatusOK, users)
40
41
25
42
func main() {
26
43
router := gin.Default()
27
44
@@ -37,6 +54,7 @@ func main() {
54
// Add this route handler
55
// with param
56
router.GET("/user/:name", getUser)
57
+ router.GET("/user", getUsers)
58
59
router.Run(":3000")
60
0 commit comments