package main

import (
	"context"
	"flag"
	"gintest/api"
	"gintest/kernel"
	"github.com/gin-gonic/gin"
	"github.com/rs/zerolog/log"
	"net/http"
	_ "net/http/pprof"
	"time"
)

func test(){
    time.Sleep(time.Second * 5)
    c.JSON(http.StatusOK, gin.H{
             "status": SUCCESS_CODE,
     })
}

func main(){
	r := gin.Default()
	//自定义变量渲染delimiter ※修改渲染变量包裹符号需要在加载模板文件之前!
	r.Delims("${", "}")
	//加载模板文件
	r.LoadHTMLGlob("templates/*")
	//加载静态资源路由
	r.Static("/static","D:\\goproject\\src\\gintest\\static")
	r.GET("/", test)
	//设置http响应时间
	s := &http.Server{
		Addr:           ":8080",
		Handler:        http.TimeoutHandler(r,time.Second * 5,""),
		ReadTimeout:    10 * time.Second,
		WriteTimeout:   10 * time.Second,
		MaxHeaderBytes: 1 << 20,
	}
	s.ListenAndServe()
}