diff --git a/cmd/badges/main.go b/cmd/badges/main.go
index e6bf5f81..2787bd1f 100644
--- a/cmd/badges/main.go
+++ b/cmd/badges/main.go
@@ -9,19 +9,45 @@ import (
)
func main() {
-
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
- //query := r.URL.Query().Get("q")
- //ext := r.URL.Query().Get("ext")
- fmt.Println(r.URL.Path)
- processPath(r.URL.Path)
- //pageSize := 20
+ _, err := processPath(r.URL.Path)
+ if err != nil {
+ w.WriteHeader(http.StatusBadRequest)
+ _, _ = w.Write([]byte("you be invalid"))
+ return
+ }
+
+ category := strings.TrimSpace(strings.ToLower(r.URL.Query().Get("category")))
+
title := "Total lines"
- text_length := "250"
+
+ switch category {
+ case "code":
+ title = "Code lines"
+ case "blanks":
+ title = "Blank lines"
+ case "comment":
+ fallthrough
+ case "comments":
+ title = "Comments"
+ case "cocomo":
+ title = "COCOMO $"
+ case "lines": // lines is the default
+ fallthrough
+ default:
+ //
+ title = "Total lines"
+ }
+
+ textLength := "250"
s := formatCount(30000)
+ if len(s) <= 3 {
+ textLength = "200"
+ }
+
w.Header().Set("Content-Type", "image/svg+xml;charset=utf-8")
- w.Write([]byte(``))
+ _, _ = w.Write([]byte(``))
})
http.ListenAndServe(":8080", nil).Error()