1
0
Fork 0
mirror of https://github.com/Luzifer/badge-gen.git synced 2024-11-08 13:20:02 +00:00
badge-gen/service_static.go

38 lines
774 B
Go
Raw Normal View History

2016-06-28 17:36:18 +00:00
package main
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
2016-06-28 21:56:22 +00:00
func (s staticServiceHandler) GetDocumentation() serviceHandlerDocumentation {
return serviceHandlerDocumentation{
ServiceName: "Static Badge",
DemoPath: "/static/API/Documentation/4c1",
Arguments: []string{"<title>", "<text>", "[color]"},
}
}
2016-06-28 17:36:18 +00:00
func (s staticServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) {
2016-06-28 21:56:22 +00:00
if len(params) < 2 {
err = errors.New("You need to provide title and text")
2016-06-28 17:36:18 +00:00
return
2016-06-28 21:56:22 +00:00
}
if len(params) < 3 {
params = append(params, defaultColor)
}
title = params[0]
text = params[1]
color = params[2]
return
2016-06-28 17:36:18 +00:00
}