-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
29 lines (23 loc) · 952 Bytes
/
Copy pathmain.go
File metadata and controls
29 lines (23 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
"contacts/frontend/frontend"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
// to associate the GET http method and the "/contacts" path to a handler function
router.GET("/contacts", frontend.ListContacts)
// to bind the POST http method and the "/contacts" path to a handler function
router.POST("/contacts", frontend.CreateContact)
// to bind the GET http method and the "/contact/:id" path to a handler function
router.GET("/contacts/:id", frontend.GetContact)
// to bind the POST http method and the "/contact/:id" path to a handler function
router.POST("/contacts/:id", frontend.UpdateContact)
// to bind the DELETE http method and the "/contact/:id" path to a handler function
router.DELETE("/contacts/:id", frontend.DeleteContact)
router.GET("/", func(ctx *gin.Context) {
ctx.JSON(201, gin.H{"message": "Server working as expected!"})
})
// run on port 80
router.Run(":8080")
}