main.go 537 B

1234567891011121314151617181920212223242526272829303132
  1. package main
  2. import (
  3. "html/template"
  4. "github.com/gin-gonic/gin"
  5. )
  6. var html = template.Must(template.New("https").Parse(`
  7. <html>
  8. <head>
  9. <title>Https Test</title>
  10. </head>
  11. <body>
  12. <h1 style="color:red;">Welcome, Ginner!</h1>
  13. </body>
  14. </html>
  15. `))
  16. func main() {
  17. r := gin.Default()
  18. r.SetHTMLTemplate(html)
  19. r.GET("/welcome", func(c *gin.Context) {
  20. c.HTML(200, "https", gin.H{
  21. "status": "success",
  22. })
  23. })
  24. // Listen and Server in https://127.0.0.1:8080
  25. r.RunTLS(":8080", "./testdata/server.pem", "./testdata/server.key")
  26. }