Created
February 9, 2018 04:48
-
-
Save xuanvan229/2d935597fdc0aedd39d13f9db21abffb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/gin-gonic/gin" | |
) | |
func main() { | |
r := gin.Default() | |
r.GET("/ping", func(c *gin.Context) { | |
c.Writer.Header().Set("Content-Type", "application/json") | |
c.Writer.Header().Set("Access-Control-Allow-Origin", "*") | |
c.Writer.Header().Set("Access-Control-Allow-Headers", "Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization") | |
c.JSON(200, gin.H{ | |
"message": "pong", | |
"id": "10", | |
}) | |
}) | |
r.POST("/post", func(c *gin.Context) { | |
fmt.Printf("hello") | |
}) | |
r.Run() // listen and serve on 0.0.0.0:8080 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment