From 47459358ae049051f3d28f7815c20890e56b92ca Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 29 Jun 2016 00:52:49 +0200 Subject: [PATCH] Deprecate /v1/badge route --- README.md | 2 +- app.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 89b6621..b745829 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/app.go b/app.go index 17445cd..a4411bf 100644 --- a/app.go +++ b/app.go @@ -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) {