mirror of
https://github.com/Luzifer/badge-gen.git
synced 2024-11-09 13:50:03 +00:00
37 lines
784 B
Go
37 lines
784 B
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
func init() {
|
|
registerServiceHandler("static", staticServiceHandler{})
|
|
}
|
|
|
|
type staticServiceHandler struct{}
|
|
|
|
func (s staticServiceHandler) GetDocumentation() serviceHandlerDocumentationList {
|
|
return serviceHandlerDocumentationList{{
|
|
ServiceName: "Static Badge",
|
|
DemoPath: "/static/API/Documentation/4c1",
|
|
Arguments: []string{"<title>", "<text>", "[color]"},
|
|
}}
|
|
}
|
|
|
|
func (s staticServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) {
|
|
if len(params) < 2 {
|
|
err = errors.New("You need to provide title and text")
|
|
return
|
|
}
|
|
|
|
if len(params) < 3 {
|
|
params = append(params, defaultColor)
|
|
}
|
|
|
|
title = params[0]
|
|
text = params[1]
|
|
color = params[2]
|
|
return
|
|
}
|