Files
mattermost/app/plugin_api_tests/manual.test_http_hijack_plugin/main.go
Mahmudul Haque a63dea6c55 unparam lint (#16771)
* fixed: `identifier` is unused lint error

* make saveMultipleMembersT method saveMultipleMembers

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
2021-02-04 11:08:05 +05:30

36 lines
685 B
Go

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
package main
import (
"net/http"
"github.com/mattermost/mattermost-server/v5/plugin"
)
type Plugin struct {
plugin.MattermostPlugin
}
func (p *Plugin) ServeHTTP(_ *plugin.Context, w http.ResponseWriter, _ *http.Request) {
hj, ok := w.(http.Hijacker)
if !ok {
w.WriteHeader(http.StatusInternalServerError)
return
}
conn, brw, err := hj.Hijack()
if conn == nil || brw == nil || err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
conn.Write([]byte("HTTP/1.1 200\n\nOK"))
conn.Close()
}
func main() {
plugin.ClientMain(&Plugin{})
}