-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
35 lines (30 loc) · 885 Bytes
/
main.go
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
30
31
32
33
34
35
package main
import (
"fmt"
"log"
"net/http"
"github.com/gin-gonic/gin"
)
// testing docker containerisation on golang:alpine package
func main() {
router := gin.Default()
router.GET("/testHeader", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "value is : %v ", // This will return a json response on /indexVal extension
})
})
router.GET("/ping", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "ping", // This will return a json response on /ping extension
})
})
router.MaxMultipartMemory = 8 << 20 // 8 MiB
router.POST("/upload", func(c *gin.Context) {
file, _ := c.FormFile("file")
log.Println(file.Filename)
dst := "/Users/shanmukhasurapuraju/containers"
c.SaveUploadedFile(file, dst)
c.String(http.StatusOK, fmt.Sprintf("'%s' uploaded!", file.Filename))
})
router.Run(":8003") // testing default port provided by gin-golang
}