As the title says , is there an api for that?
*fasthttp.Request.Header.key
When I call the method with POSTMAN , I can't get the header content key as the above code . Why
As the title says , is there an api for that?
*fasthttp.Request.Header.key
When I call the method with POSTMAN , I can't get the header content key as the above code . Why
It may surprise you to learn that fasthttp doesn't store request header values as an exported map[string]string
, but as an unexported []byte
which it stores indexes into. This apparently is one of its performance optimizations.
You can get a request header value with Peek()
.
v := ctx.Request.Header.Peek("User-Agent")
Note that this function returns a byte slice, so you'll probably have to convert it to a string
.
sv := string(v)