summaryrefslogtreecommitdiffstats
path: root/plugin/client_rpc.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2018-07-06 06:07:09 -0700
committerJoram Wilander <jwawilander@gmail.com>2018-07-06 09:07:09 -0400
commit4c1ddcff10b359baf5728b334acb60cc3e1b1123 (patch)
tree40e9ae1aa914c7a8676da8ae3e10fbc8e2b36d95 /plugin/client_rpc.go
parent7bfb5aec26c6bb8c49fa19e8347bc91acc86fe92 (diff)
downloadchat-4c1ddcff10b359baf5728b334acb60cc3e1b1123.tar.gz
chat-4c1ddcff10b359baf5728b334acb60cc3e1b1123.tar.bz2
chat-4c1ddcff10b359baf5728b334acb60cc3e1b1123.zip
MM-10703 Adding blank request context to plugin hooks for future use. (#9043)
* Adding blank request context to plugin hooks for future use. * Rename RequestContext to Context * Adding context to ServeHTTP and ExecuteCommand * Fixing import cycle in test.
Diffstat (limited to 'plugin/client_rpc.go')
-rw-r--r--plugin/client_rpc.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/plugin/client_rpc.go b/plugin/client_rpc.go
index f58bbd22b..39d91a3e7 100644
--- a/plugin/client_rpc.go
+++ b/plugin/client_rpc.go
@@ -226,10 +226,11 @@ func init() {
type ServeHTTPArgs struct {
ResponseWriterStream uint32
Request *http.Request
+ Context *Context
RequestBodyStream uint32
}
-func (g *HooksRPCClient) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+func (g *HooksRPCClient) ServeHTTP(c *Context, w http.ResponseWriter, r *http.Request) {
if !g.implemented[ServeHTTPId] {
http.NotFound(w, r)
return
@@ -282,6 +283,7 @@ func (g *HooksRPCClient) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
if err := g.client.Call("Plugin.ServeHTTP", ServeHTTPArgs{
+ Context: c,
ResponseWriterStream: serveHTTPStreamId,
Request: forwardedRequest,
RequestBodyStream: requestBodyStreamId,
@@ -314,8 +316,10 @@ func (s *HooksRPCServer) ServeHTTP(args *ServeHTTPArgs, returns *struct{}) error
}
defer r.Body.Close()
- if hook, ok := s.impl.(http.Handler); ok {
- hook.ServeHTTP(w, r)
+ if hook, ok := s.impl.(interface {
+ ServeHTTP(c *Context, w http.ResponseWriter, r *http.Request)
+ }); ok {
+ hook.ServeHTTP(args.Context, w, r)
} else {
http.NotFound(w, r)
}