Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all headers in array

Tags:

go

fasthttp

I tried to get all headers in handler and faced some difficulties.

valyala/fasthttp has the needed methods and I can get headlines one by one, but I don`t see the obvious way to get all of the headers.

So, How can I get all of the headers into an array?

like image 272
BlackFox Avatar asked Aug 03 '26 09:08

BlackFox


1 Answers

Use request.Header.VisitAll. See related doc.

r.Header.VisitAll(func (key, value []byte) {
    log.Printf("%v: %v", key, value)
})
like image 102
Arman Ordookhani Avatar answered Aug 05 '26 23:08

Arman Ordookhani