Search code examples
httpparsinggoheaderfasthttp

Get arbitary request header value in 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?


Solution

  • Found it.

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