func (p *Plugin) showEphemeral(w http.ResponseWriter, r *http.Request) {
	request := model.PostActionIntegrationRequestFromJson(r.Body)
	if request == nil || request.Context == nil {
		w.WriteHeader(http.StatusBadRequest)
		return
	}
	response := &model.PostActionIntegrationResponse{
		EphemeralText: request.Context["spoiler"].(string),
	}
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)
	_, _ = w.Write(response.ToJson())
}
Show spoiler content as an ephemeral message
package main
import (
	"fmt"
	"net/http"
	"strings"
	"sync"
	"github.com/mattermost/mattermost-server/v5/model"
	"github.com/mattermost/mattermost-server/v5/plugin"
)
type Plugin struct {
	plugin.MattermostPlugin
	configurationLock sync.RWMutex
	configuration *Configuration
}
const (
	trigger        = "spoiler"
	customPostType = "custom_spoiler"
	customPostProp = "CustomSpoilerRawMessage"
)
func (p *Plugin) OnActivate() error {
	return p.API.RegisterCommand(&model.Command{
		Trigger:          trigger,
		Description:      "Hide a message that contains a spoiler",
		DisplayName:      "Spoiler",
		AutoComplete:     true,
		AutoCompleteDesc: "Hide a spoiler message",
		AutoCompleteHint: "The Titanic sinks at the end.",
	})
}
func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
	switch r.URL.Path {
	case "/show":
		p.showEphemeral(w, r)
	case "/config":
		p.handleConfigRequest(w, r)
	default:
		http.NotFound(w, r)
	}
}
func (p *Plugin) ExecuteCommand(c *plugin.Context, args *model.CommandArgs) (*model.CommandResponse, *model.AppError) {
	rawText := strings.TrimSpace((strings.Replace(args.Command, "/"+trigger, "", 1)))
	_, err := p.API.CreatePost(p.getSpoilerPost(args.UserId, args.ChannelId, args.RootId, rawText))
	if err != nil {
		return nil, err
	}
	return &model.CommandResponse{}, nil
}
func (p *Plugin) getSpoilerPost(userID, channelID, rootID, spoiler string) *model.Post {
	return &model.Post{
		UserId:    userID,
		ChannelId: channelID,
		Type:      customPostType,
		RootId:    rootID,
		Props: map[string]interface{}{
			customPostProp: spoiler,
			"attachments":  p.getPostAttachments(spoiler),
		},
	}
}
func (p *Plugin) getPostAttachments(spoilerText string) []*model.SlackAttachment {
	actions := []*model.PostAction{{
		Name: "Show spoiler",
		Type: model.POST_ACTION_TYPE_BUTTON,
		Integration: &model.PostActionIntegration{
			URL:     fmt.Sprintf("/plugins/%s/show", manifest.Id),
			Context: model.StringInterface{"spoiler": spoilerText},
		},
	},
	}
	return []*model.SlackAttachment{{
		Actions: actions,
	}}
}