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

Deprecate /v1/badge route

This commit is contained in:
Knut Ahlers 2016-06-29 00:52:49 +02:00
parent 0342b26a10
commit 47459358ae
Signed by: luzifer
GPG Key ID: DC2729FDD34BE99E
2 changed files with 7 additions and 2 deletions

View File

@ -11,7 +11,7 @@ And I wasn't myself if I would allow me to do the same work twice or more often
Simple use the raw-API URL below or one of the URLs listed on the [demo page](https://badge.luzifer.io/):
```
https://badge.luzifer.io/v1/badge?title=API&text=Documentation&color=4c1
https://badge.luzifer.io/static/API/Documentation/4c1
```
Parameters `title` and `text` are free-text strings while `color` has to be 3- or 6-letter hex notation for colors like that one you use in CSS.

7
app.go
View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"
"sort"
"strings"
"text/template"
@ -116,7 +117,11 @@ func generateBadge(res http.ResponseWriter, r *http.Request) {
color = defaultColor
}
renderBadgeToResponse(res, r, title, text, color)
http.Redirect(res, r, fmt.Sprintf("/static/%s/%s/%s",
url.QueryEscape(title),
url.QueryEscape(text),
url.QueryEscape(color),
), http.StatusMovedPermanently)
}
func renderBadgeToResponse(res http.ResponseWriter, r *http.Request, title, text, color string) {