2016-06-28 17:36:18 +00:00
|
|
|
package main
|
|
|
|
|
2016-06-28 22:51:51 +00:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
2016-06-28 17:36:18 +00:00
|
|
|
|
|
|
|
func init() {
|
2016-06-28 21:56:22 +00:00
|
|
|
registerServiceHandler("static", staticServiceHandler{})
|
|
|
|
}
|
|
|
|
|
|
|
|
type staticServiceHandler struct{}
|
2016-06-28 17:36:18 +00:00
|
|
|
|
2023-09-08 12:23:22 +00:00
|
|
|
func (staticServiceHandler) GetDocumentation() serviceHandlerDocumentationList {
|
2016-06-29 11:09:08 +00:00
|
|
|
return serviceHandlerDocumentationList{{
|
2016-06-28 21:56:22 +00:00
|
|
|
ServiceName: "Static Badge",
|
|
|
|
DemoPath: "/static/API/Documentation/4c1",
|
|
|
|
Arguments: []string{"<title>", "<text>", "[color]"},
|
2016-06-29 11:09:08 +00:00
|
|
|
}}
|
2016-06-28 21:56:22 +00:00
|
|
|
}
|
2016-06-28 17:36:18 +00:00
|
|
|
|
2021-03-11 10:16:15 +00:00
|
|
|
func (staticServiceHandler) IsEnabled() bool { return true }
|
|
|
|
|
2023-09-08 12:23:22 +00:00
|
|
|
func (staticServiceHandler) Handle(_ context.Context, params []string) (title, text, color string, err error) {
|
|
|
|
if len(params) < 2 { //nolint:gomnd
|
|
|
|
err = errors.New("you need to provide title and text")
|
|
|
|
return title, text, color, err
|
2016-06-28 21:56:22 +00:00
|
|
|
}
|
|
|
|
|
2023-09-08 12:23:22 +00:00
|
|
|
if len(params) < 3 { //nolint:gomnd
|
2016-06-28 21:56:22 +00:00
|
|
|
params = append(params, defaultColor)
|
|
|
|
}
|
|
|
|
|
|
|
|
title = params[0]
|
|
|
|
text = params[1]
|
|
|
|
color = params[2]
|
2023-09-08 12:23:22 +00:00
|
|
|
return title, text, color, err
|
2016-06-28 17:36:18 +00:00
|
|
|
}
|