Search code examples
gofasthttp

How to get all headers in array


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?


Solution

  • Use request.Header.VisitAll. See related doc.

    r.Header.VisitAll(func (key, value []byte) {
        log.Printf("%v: %v", key, value)
    })