From f9f41f790012f25a06cb80fe5a281d4fc1fcc8d2 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 29 Jun 2016 13:09:08 +0200 Subject: [PATCH] Allow multiple documentation entries per handler --- app.go | 10 ++++++---- service_static.go | 6 +++--- service_travis.go | 6 +++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app.go b/app.go index a4411bf..31b4ae3 100644 --- a/app.go +++ b/app.go @@ -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) diff --git a/service_static.go b/service_static.go index 653d6fd..0ba1e90 100644 --- a/service_static.go +++ b/service_static.go @@ -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{"", "<text>", "[color]"}, - } + }} } func (s staticServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) { diff --git a/service_travis.go b/service_travis.go index afdd465..956955a 100644 --- a/service_travis.go +++ b/service_travis.go @@ -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) {