diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-06-25 12:33:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-25 12:33:13 -0700 |
commit | 1e5c432e1029601a664454388ae366ef69618d62 (patch) | |
tree | cb9e8bfb66640ac3b29c934bb2c3202d25aeb368 /plugin/example_hello_user_test.go | |
parent | ecefa6cdd1e7376046bbec82c1b47f7756fea646 (diff) | |
download | chat-1e5c432e1029601a664454388ae366ef69618d62.tar.gz chat-1e5c432e1029601a664454388ae366ef69618d62.tar.bz2 chat-1e5c432e1029601a664454388ae366ef69618d62.zip |
MM-10702 Moving plugins to use hashicorp go-plugin. (#8978)
* Moving plugins to use hashicorp go-plugin.
* Tweaks from feedback.
Diffstat (limited to 'plugin/example_hello_user_test.go')
-rw-r--r-- | plugin/example_hello_user_test.go | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/plugin/example_hello_user_test.go b/plugin/example_hello_user_test.go deleted file mode 100644 index 989cca0f2..000000000 --- a/plugin/example_hello_user_test.go +++ /dev/null @@ -1,39 +0,0 @@ -package plugin_test - -import ( - "fmt" - "net/http" - - "github.com/mattermost/mattermost-server/plugin" - "github.com/mattermost/mattermost-server/plugin/rpcplugin" -) - -type HelloUserPlugin struct { - api plugin.API -} - -func (p *HelloUserPlugin) OnActivate(api plugin.API) error { - // Just save api for later when we need to look up users. - p.api = api - return nil -} - -func (p *HelloUserPlugin) ServeHTTP(w http.ResponseWriter, r *http.Request) { - if userId := r.Header.Get("Mattermost-User-Id"); userId == "" { - // Our visitor is unauthenticated. - fmt.Fprintf(w, "Hello, stranger!") - } else if user, err := p.api.GetUser(userId); err == nil { - // Greet the user by name! - fmt.Fprintf(w, "Welcome back, %v!", user.Username) - } else { - // This won't happen in normal circumstances, but let's just be safe. - w.WriteHeader(http.StatusInternalServerError) - fmt.Fprintf(w, err.Error()) - } -} - -// This example demonstrates a plugin that handles HTTP requests which respond by greeting the user -// by name. -func Example_helloUser() { - rpcplugin.Main(&HelloUserPlugin{}) -} |