Skip to content

Instantly share code, notes, and snippets.

@gszr
Last active July 3, 2024 16:29
Show Gist options
  • Save gszr/75ae222c94af1b1167426fce0237b396 to your computer and use it in GitHub Desktop.
Save gszr/75ae222c94af1b1167426fce0237b396 to your computer and use it in GitHub Desktop.
Go Plugin Demo
/*
A "hello world" plugin in Go,
which reads a request header and sets a response header.
*/
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.2"
var Priority = 1
type Config struct {
Message string
}
func New() interface{} {
return &Config{}
}
func (conf *Config) Response(kong *pdk.PDK) {
headerKeyResponse, err := kong.Response.GetHeaders(-1)
log.Println(headerKeyResponse)
log.Println(err)
}
module github.com/Kong/go-plugins
go 1.22
require github.com/Kong/go-pdk v0.11.0
require (
github.com/ugorji/go/codec v1.2.12 // indirect
google.golang.org/protobuf v1.33.0 // indirect
)
replace github.com/Kong/go-pdk => ../../../go-pdk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment