2 Star 2 Fork 0

大佬金/kong网关之go插件开发

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
go-hello.go 616 Bytes
一键复制 编辑 原始数据 按行查看 历史
jijj@create80.com 提交于 2021-12-24 10:41 . 初始化
package main
import (
"fmt"
"github.com/Kong/go-pdk"
"github.com/Kong/go-pdk/server"
"log"
)
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) Access(kong *pdk.PDK) {
host, err := kong.Request.GetHeader("host")
if err != nil {
log.Printf("Error reading 'host' header: %s", err.Error())
}
message := conf.Message
if message == "" {
message = "hello"
}
kong.Response.SetHeader("x-hello-from-go", fmt.Sprintf("Go says %s to %s", message, host))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/BossKing/go-plug-in-of-kong-gateway.git
git@gitee.com:BossKing/go-plug-in-of-kong-gateway.git
BossKing
go-plug-in-of-kong-gateway
kong网关之go插件开发
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385