Last active
July 3, 2024 16:29
-
-
Save gszr/75ae222c94af1b1167426fce0237b396 to your computer and use it in GitHub Desktop.
Go Plugin Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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