mirror of
https://github.com/Kong/go-pluginserver.git
synced 2025-09-27 12:32:10 +08:00
feat(*) add response phase (#32)
This commit is contained in:
@@ -23,8 +23,7 @@ type (
|
||||
certificater interface{ Certificate(*pdk.PDK) }
|
||||
rewriter interface{ Rewrite(*pdk.PDK) }
|
||||
accesser interface{ Access(*pdk.PDK) }
|
||||
headerFilter interface{ HeaderFilter(*pdk.PDK) }
|
||||
bodyFilter interface{ BodyFilter(*pdk.PDK) }
|
||||
responser interface{ Response(*pdk.PDK) }
|
||||
prereader interface{ Preread(*pdk.PDK) }
|
||||
logger interface{ Log(*pdk.PDK) }
|
||||
)
|
||||
@@ -35,15 +34,13 @@ func getHandlers(config interface{}) map[string]func(kong *pdk.PDK) {
|
||||
if h, ok := config.(certificater); ok { handlers["certificate"] = h.Certificate }
|
||||
if h, ok := config.(rewriter) ; ok { handlers["rewrite"] = h.Rewrite }
|
||||
if h, ok := config.(accesser) ; ok { handlers["access"] = h.Access }
|
||||
if h, ok := config.(headerFilter); ok { handlers["header_filter"] = h.HeaderFilter }
|
||||
if h, ok := config.(bodyFilter) ; ok { handlers["body_filter"] = h.BodyFilter }
|
||||
if h, ok := config.(responser) ; ok { handlers["response"] = h.Response }
|
||||
if h, ok := config.(prereader) ; ok { handlers["preread"] = h.Preread }
|
||||
if h, ok := config.(logger) ; ok { handlers["log"] = h.Log }
|
||||
|
||||
return handlers
|
||||
}
|
||||
|
||||
|
||||
func (s *PluginServer) expireInstances() error {
|
||||
const instanceTimeout = 60
|
||||
expirationCutoff := time.Now().Add(time.Second * -instanceTimeout)
|
||||
@@ -131,7 +128,6 @@ func (s *PluginServer) StartInstance(config PluginConfig, status *InstanceStatus
|
||||
|
||||
log.Printf("Started instance %#v:%v", config.Name, instance.id)
|
||||
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
6
main.go
6
main.go
@@ -4,14 +4,14 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"runtime"
|
||||
"fmt"
|
||||
"github.com/ugorji/go/codec"
|
||||
"log"
|
||||
"net"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"reflect"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -118,7 +118,7 @@ func main() {
|
||||
if socket != "" {
|
||||
go func() {
|
||||
for {
|
||||
if ! isParentAlive() {
|
||||
if !isParentAlive() {
|
||||
log.Printf("Kong exited; shutting down...")
|
||||
os.Exit(0)
|
||||
}
|
||||
|
Reference in New Issue
Block a user