RegisterWebhook implements plugin.Webhooker.
(baseURL string, g *gin.RouterGroup)
| 73 | |
| 74 | // RegisterWebhook implements plugin.Webhooker. |
| 75 | func (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. |
| 98 | func (c *EchoPlugin) GetDisplay(location *url.URL) string { |
nothing calls this directly
no test coverage detected