-
Notifications
You must be signed in to change notification settings - Fork 50
/
pdk.go
69 lines (61 loc) · 1.94 KB
/
pdk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Package Kong/go-pdk implements Kong's Plugin Development Kit for Go.
It directly parallels the existing kong PDK for Lua plugins.
Kong plugins written in Go implement event handlers as methods on the Plugin's
structure, with the given signature:
func (conf *MyConfig) Access (kong *pdk.PDK) {
...
}
The `kong` argument of type `*pdk.PDK` is the entrypoint for all PDK functions.
For example, to get the client's IP address, you'd use `kong.Client.GetIp()`.
*/
package pdk
import (
"net"
"github.com/Kong/go-pdk/bridge"
"github.com/Kong/go-pdk/client"
"github.com/Kong/go-pdk/ctx"
"github.com/Kong/go-pdk/ip"
"github.com/Kong/go-pdk/log"
"github.com/Kong/go-pdk/nginx"
"github.com/Kong/go-pdk/node"
"github.com/Kong/go-pdk/request"
"github.com/Kong/go-pdk/response"
"github.com/Kong/go-pdk/router"
"github.com/Kong/go-pdk/service"
service_request "github.com/Kong/go-pdk/service/request"
service_response "github.com/Kong/go-pdk/service/response"
)
// PDK go pdk module
type PDK struct {
Client client.Client
Ctx ctx.Ctx
Log log.Log
Nginx nginx.Nginx
Request request.Request
Response response.Response
Router router.Router
IP ip.Ip
Node node.Node
Service service.Service
ServiceRequest service_request.Request
ServiceResponse service_response.Response
}
// Init initialize go pdk. Called by the pluginserver at initialization.
func Init(conn net.Conn) *PDK {
b := bridge.New(conn)
return &PDK{
Client: client.Client{b},
Ctx: ctx.Ctx{b},
Log: log.Log{b},
Nginx: nginx.Nginx{b},
Request: request.Request{b},
Response: response.Response{b},
Router: router.Router{b},
IP: ip.Ip{b},
Node: node.Node{b},
Service: service.Service{b},
ServiceRequest: service_request.Request{b},
ServiceResponse: service_response.Response{b},
}
}