|
|
@ -1,9 +1,11 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
"text/template"
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
"net/http"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
@ -14,20 +16,54 @@ const (
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
func main() {
|
|
|
|
t := template.New("svgConv")
|
|
|
|
//_ := template.New("svgConv")
|
|
|
|
|
|
|
|
|
|
|
|
percentage := 0.999
|
|
|
|
//percentage := 0.999
|
|
|
|
fill := percentageToRGB(percentage)
|
|
|
|
//fill := percentageToRGB(percentage)
|
|
|
|
|
|
|
|
|
|
|
|
pill := CoveragePill{
|
|
|
|
//_ := CoveragePill{
|
|
|
|
fmt.Sprintf("%.1f", toFixed(percentage, 3)*100),
|
|
|
|
// fmt.Sprintf("%.1f", toFixed(percentage, 3)*100),
|
|
|
|
baseColour,
|
|
|
|
// baseColour,
|
|
|
|
fill,
|
|
|
|
// fill,
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
r := mux.NewRouter()
|
|
|
|
|
|
|
|
r.HandleFunc("/upload/go", upload)
|
|
|
|
|
|
|
|
_ = http.ListenAndServe(":8080", r)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func upload(w http.ResponseWriter, r *http.Request) {
|
|
|
|
|
|
|
|
if r.Method != "POST" {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err := r.ParseForm()
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
|
|
|
http.Error(w, "Request parameters not parsed", 500)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
t, err := t.Parse(svgTemplate)
|
|
|
|
err = r.ParseMultipartForm(5 << 20)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
http.Error(w, "Request parameters not parsed", 500)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
form := r.Form
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
project := form.Get("project")
|
|
|
|
|
|
|
|
tag := form.Get("tag")
|
|
|
|
|
|
|
|
id := form.Get("id")
|
|
|
|
|
|
|
|
file, _, err := r.FormFile("file")
|
|
|
|
|
|
|
|
b, _ := ioutil.ReadAll(file)
|
|
|
|
|
|
|
|
n := bytes.Index(b, []byte{0})
|
|
|
|
|
|
|
|
content := string(b[n])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Print(content)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if project == "" || tag == "" || id == "" {
|
|
|
|
|
|
|
|
http.Error(w, "Request parameters [secret, project, tag, id] not found", 400)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_ = t.Execute(os.Stdout, pill)
|
|
|
|
_, _ = fmt.Fprintf(w, "project: '%s'\ntag: '%s'\nid: '%s'\n", project, tag, id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|