• 定义请求头 在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
        }
    1. Access-Control-Allow-Headers:
      Content-Type,X-Accesstoken,X-Action
    2. Access-Control-Allow-Methods:
      OPTIONS,POST
    3. Access-Control-Allow-Origin:
      *
    4. Connection:
      keep-alive
    5. Content-Length:
      135
    6. Content-Type:
      text/plain; charset=utf-8
    7. Date:
      Fri, 25 Feb 2022 08:34:22 GMT
    8. Server:
      nginx/1.10.3 (Ubuntu)
    9. X-Build-Time:
      2022-02-25--16:22:56
    10. X-Req-Id:
      7a74a12b-9f1a-4d06-a83d-bd3da9340bb5
  • 相关阅读:
    codevs 1164 统计数字
    codevs 2597 团伙
    codevs 1472 体检
    Openjudge 1.13-21:最大质因子序列
    Openjudge 1.13-23:区间内的真素数
    codevs 1388 砍树
    codevs 1536 海战
    codevs 3110 二叉堆练习3
    codevs 2879 堆的判断
    Openjudge 1.13.37:乒乓球
  • 原文地址:https://www.cnblogs.com/rsapaper/p/15936723.html
Copyright © 2020-2023  润新知