MCPcopy
hub / github.com/gotify/server / RegisterWebhook

Method RegisterWebhook

plugin/example/echo/echo.go:75–95  ·  view source on GitHub ↗

RegisterWebhook implements plugin.Webhooker.

(baseURL string, g *gin.RouterGroup)

Source from the content-addressed store, hash-verified

73
74// RegisterWebhook implements plugin.Webhooker.
75func (c *EchoPlugin) RegisterWebhook(baseURL string, g *gin.RouterGroup) {
76 c.basePath = baseURL
77 g.GET("/echo", func(ctx *gin.Context) {
78 storage, _ := c.storageHandler.Load()
79 conf := new(Storage)
80 json.Unmarshal(storage, conf)
81 conf.CalledTimes++
82 newStorage, _ := json.Marshal(conf)
83 c.storageHandler.Save(newStorage)
84
85 c.msgHandler.SendMessage(plugin.Message{
86 Title: "Hello received",
87 Message: fmt.Sprintf("echo server received a hello message %d times", conf.CalledTimes),
88 Priority: 2,
89 Extras: map[string]interface{}{
90 "plugin::name": "echo",
91 },
92 })
93 ctx.Writer.WriteString(fmt.Sprintf("Magic string is: %s\r\nEcho server running at %secho", c.config.MagicString, c.basePath))
94 })
95}
96
97// GetDisplay implements plugin.Displayer.
98func (c *EchoPlugin) GetDisplay(location *url.URL) string {

Callers

nothing calls this directly

Calls 3

LoadMethod · 0.65
SaveMethod · 0.65
SendMessageMethod · 0.65

Tested by

no test coverage detected