~/src/tmp/go-pdk-bug-2 % go test
2023/02/08 17:54:55 header: Cookie
2023/02/08 17:54:55 value: [fun=1]
PASS
ok plugintest 0.154s
Here above you see the key comes out as Cookie when running the tests. But when running the plugin in kong, it come out as cookie as per the docs.
This is the key of the map returned from calling kong.Request.GetHeaders(-1)
The full contents of the main and test files are below.
// main.go
package main
import (
"log"
"github.com/Kong/go-pdk"
"github.com/Kong/go-pdk/server"
)
func main() {
server.StartServer(New, Version, Priority)
}
var Version = "0.0.1"
var Priority = 1
type Config struct{}
func New() interface{} {
return &Config{}
}
func (conf Config) Access(kong *pdk.PDK) {
headers, err := kong.Request.GetHeaders(-1)
if err != nil {
kong.Response.ExitStatus(500)
}
for k, v := range headers {
log.Printf("header: %v", k)
log.Printf("value: %v", v)
}
}
kong.Request.GetHeaders
should return a map with the headers normalised in lower case. ( https://github.com/Kong/go-pdk/blob/4deec45a5bfe421a0ceebcbf7931d395250949b0/request/request.go#L179-L180 )Here above you see the key comes out as
Cookie
when running the tests. But when running the plugin in kong, it come out ascookie
as per the docs. This is the key of the map returned from callingkong.Request.GetHeaders(-1)
The full contents of the main and test files are below.go.mod