定义请求头 在header中返回编译时间
#!/bin/sh
BuildTime=$(date '+%Y-%m-%d--%H:%M:%S')
echo $BuildTime
build=`go build -ldflags "-X main.BuildTime=$BuildTime"`
echo $build
ResponseEncoder := func(w ghttp.ResponseWriter, r *ghttp.Request, v interface{}) error {
codec, _ := http.CodecForRequest(r, "Accept")
data, err := codec.Marshal(v)
if err != nil {
return err
}
w.Header().Set("X-Build-Time", sreCli.BuildTime)
_, err = w.Write(data)
if err != nil {
return err
}
return nil
}