mirror of
https://github.com/Luzifer/badge-gen.git
synced 2024-11-09 22:00:05 +00:00
Deprecate /v1/badge route
This commit is contained in:
parent
0342b26a10
commit
47459358ae
2 changed files with 7 additions and 2 deletions
|
@ -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/):
|
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.
|
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
7
app.go
|
@ -6,6 +6,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
@ -116,7 +117,11 @@ func generateBadge(res http.ResponseWriter, r *http.Request) {
|
||||||
color = defaultColor
|
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) {
|
func renderBadgeToResponse(res http.ResponseWriter, r *http.Request, title, text, color string) {
|
||||||
|
|
Loading…
Reference in a new issue