mirror of
https://github.com/Luzifer/badge-gen.git
synced 2024-11-09 22:00:05 +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] }
|
func (s serviceHandlerDocumentationList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
|
||||||
type serviceHandler interface {
|
type serviceHandler interface {
|
||||||
GetDocumentation() serviceHandlerDocumentation
|
GetDocumentation() serviceHandlerDocumentationList
|
||||||
Handle(ctx context.Context, params []string) (title, text, color string, err error)
|
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{}
|
examples := serviceHandlerDocumentationList{}
|
||||||
|
|
||||||
for register, handler := range serviceHandlers {
|
for register, handler := range serviceHandlers {
|
||||||
tmp := handler.GetDocumentation()
|
tmps := handler.GetDocumentation()
|
||||||
tmp.Register = register
|
for _, tmp := range tmps {
|
||||||
examples = append(examples, tmp)
|
tmp.Register = register
|
||||||
|
examples = append(examples, tmp)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sort.Sort(examples)
|
sort.Sort(examples)
|
||||||
|
|
|
@ -12,12 +12,12 @@ func init() {
|
||||||
|
|
||||||
type staticServiceHandler struct{}
|
type staticServiceHandler struct{}
|
||||||
|
|
||||||
func (s staticServiceHandler) GetDocumentation() serviceHandlerDocumentation {
|
func (s staticServiceHandler) GetDocumentation() serviceHandlerDocumentationList {
|
||||||
return serviceHandlerDocumentation{
|
return serviceHandlerDocumentationList{{
|
||||||
ServiceName: "Static Badge",
|
ServiceName: "Static Badge",
|
||||||
DemoPath: "/static/API/Documentation/4c1",
|
DemoPath: "/static/API/Documentation/4c1",
|
||||||
Arguments: []string{"<title>", "<text>", "[color]"},
|
Arguments: []string{"<title>", "<text>", "[color]"},
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s staticServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) {
|
func (s staticServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) {
|
||||||
|
|
|
@ -16,12 +16,12 @@ func init() {
|
||||||
|
|
||||||
type travisServiceHandler struct{}
|
type travisServiceHandler struct{}
|
||||||
|
|
||||||
func (t travisServiceHandler) GetDocumentation() serviceHandlerDocumentation {
|
func (t travisServiceHandler) GetDocumentation() serviceHandlerDocumentationList {
|
||||||
return serviceHandlerDocumentation{
|
return serviceHandlerDocumentationList{{
|
||||||
ServiceName: "Travis-CI",
|
ServiceName: "Travis-CI",
|
||||||
DemoPath: "/travis/Luzifer/password",
|
DemoPath: "/travis/Luzifer/password",
|
||||||
Arguments: []string{"<user>", "<repo>", "[branch]"},
|
Arguments: []string{"<user>", "<repo>", "[branch]"},
|
||||||
}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t travisServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) {
|
func (t travisServiceHandler) Handle(ctx context.Context, params []string) (title, text, color string, err error) {
|
||||||
|
|
Loading…
Reference in a new issue