1
0
mirror of https://github.com/Luzifer/badge-gen.git synced 2024-09-19 15:23:04 +00:00

Allow multiple documentation entries per handler

This commit is contained in:
Knut Ahlers 2016-06-29 13:09:08 +02:00
parent d3d68d76b0
commit f9f41f7900
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E
3 changed files with 12 additions and 10 deletions

10
app.go
View File

@ -54,7 +54,7 @@ func (s serviceHandlerDocumentationList) Less(i, j int) bool {
func (s serviceHandlerDocumentationList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
type serviceHandler interface {
GetDocumentation() serviceHandlerDocumentation
GetDocumentation() serviceHandlerDocumentationList
Handle(ctx context.Context, params []string) (title, text, color string, err error)
}
@ -180,9 +180,11 @@ func handleDemoPage(res http.ResponseWriter, r *http.Request) {
examples := serviceHandlerDocumentationList{}
for register, handler := range serviceHandlers {
tmp := handler.GetDocumentation()
tmp.Register = register
examples = append(examples, tmp)
tmps := handler.GetDocumentation()
for _, tmp := range tmps {
tmp.Register = register
examples = append(examples, tmp)
}
}
sort.Sort(examples)

View File

@ -12,12 +12,12 @@ func init() {
type staticServiceHandler struct{}
func (s staticServiceHandler) GetDocumentation() serviceHandlerDocumentation {
return serviceHandlerDocumentation{
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) {

View File

@ -16,12 +16,12 @@ func init() {
type travisServiceHandler struct{}
func (t travisServiceHandler) GetDocumentation() serviceHandlerDocumentation {
return serviceHandlerDocumentation{
func (t travisServiceHandler) GetDocumentation() serviceHandlerDocumentationList {
return serviceHandlerDocumentationList{{
ServiceName: "Travis-CI",
DemoPath: "/travis/Luzifer/password",
Arguments: []string{"<user>", "<repo>", "[branch]"},
}
}}
}
func (t travisServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) {