I found a way to make it an HTTPS server with Go / Gin from Gin's Github, so I will write it instead of a memo.
[environment] go version go1.15.2 darwin/amd64
[Reference URL] https://github.com/gin-gonic/gin README.md
httpd.go
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.String(200, "Hello Gin!!")
})
r.Run()
httpd.go
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.String(200, "Hello Gin!!")
})
r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
As described above, If you change "r.Run" to "r.RunTLS", it becomes an https server. The first argument of r.RunTLS is the port number, and the second and third arguments are the certificate path.
that's all.
Recommended Posts