Skip to content

Instantly share code, notes, and snippets.

@gavinzhou
Created November 7, 2018 12:08
Show Gist options
  • Save gavinzhou/2fd47b42ff7a51c48d82f3ebcf17e1e6 to your computer and use it in GitHub Desktop.
Save gavinzhou/2fd47b42ff7a51c48d82f3ebcf17e1e6 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"net/http"
"github.com/gavinzhou/hello-gin/pkg/setting"
"github.com/gin-gonic/gin"
)
func main() {
router := gin.Default()
router.GET("/test", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "test",
})
})
config, err := setting.NewConfig()
if err != nil {
log.Fatal("Can init Config with Environment: %v", err)
}
s := &http.Server{
Addr: fmt.Sprintf(":%d", config.HTTPPort),
Handler: router,
ReadTimeout: config.ReadTimeout,
WriteTimeout: config.WriteTimeout,
MaxHeaderBytes: 1 << 20,
}
s.ListenAndServe()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment