duananyantan04633 2016-09-01 08:07
浏览 719
已采纳

在golang fasthttp中获取任意请求标头值

Searched through docs and read source, could not find anyway to access something like

ctx.Request.Header.Get("X-Forwarded-For")

I see in header.go, the type RequestHeader struct is defined something like

h     []argsKV
bufKV argsKV

cookies []argsKV

rawHeaders []byte

Is it possible to access these fields without reflection at all?

  • 写回答

1条回答 默认 最新

  • doujian1050 2016-09-01 09:34
    关注

    Found it.

    ctx.Request.Header.Peek("X-Forwarded-For")
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?