|
|
@ -20,7 +20,7 @@ func StartServer(port string) {
|
|
|
|
r.HandleFunc("/badge/pulls/{namespace}/{project}/{pull}", handlePullBadge)
|
|
|
|
r.HandleFunc("/badge/pulls/{namespace}/{project}/{pull}", handlePullBadge)
|
|
|
|
|
|
|
|
|
|
|
|
r.HandleFunc("/upload/branch/{namespace}/{project}/{branch}", uploadBranch)
|
|
|
|
r.HandleFunc("/upload/branch/{namespace}/{project}/{branch}", uploadBranch)
|
|
|
|
r.HandleFunc("/upload/pulls/{namespace}/{project}/{branch}", uploadPull)
|
|
|
|
r.HandleFunc("/upload/pulls/{namespace}/{project}/{pull}", uploadPull)
|
|
|
|
|
|
|
|
|
|
|
|
portStr := fmt.Sprintf(":%s", port)
|
|
|
|
portStr := fmt.Sprintf(":%s", port)
|
|
|
|
err := http.ListenAndServe(portStr, r)
|
|
|
|
err := http.ListenAndServe(portStr, r)
|
|
|
@ -51,3 +51,26 @@ func handleBadge(w http.ResponseWriter, r *http.Request) {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getAllParams(w http.ResponseWriter, r *http.Request, thirdParam string) ([3]string, bool) {
|
|
|
|
|
|
|
|
vars := mux.Vars(r)
|
|
|
|
|
|
|
|
namespace, ok := vars["namespace"]
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
http.Error(w, "Path 'namespace' not found", http.StatusBadRequest)
|
|
|
|
|
|
|
|
return [3]string{}, false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
project, ok := vars["project"]
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
http.Error(w, "Path 'project' not found", http.StatusBadRequest)
|
|
|
|
|
|
|
|
return [3]string{}, false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
third, ok := vars[thirdParam]
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
http.Error(w, fmt.Sprintf("Path '%s' not found", thirdParam), http.StatusBadRequest)
|
|
|
|
|
|
|
|
return [3]string{}, false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return [3]string{namespace, project, third}, true
|
|
|
|
|
|
|
|
}
|
|
|
|