mirror of
https://github.com/Luzifer/badge-gen.git
synced 2024-11-08 13:20:02 +00:00
Allow multiple documentation entries per handler
This commit is contained in:
parent
d3d68d76b0
commit
f9f41f7900
3 changed files with 12 additions and 10 deletions
10
app.go
10
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)
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue