func GrantAccess(w http.ResponseWriter, r *http.Request) {
	// TODO: update README
	repositories, users, err := accessParameters(r.Body)
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	if err := repository.GrantAccess(repositories, users); err != nil {
		http.Error(w, err.Error(), http.StatusNotFound)
		return
	}
	fmt.Fprintf(w, "Successfully granted access to users \"%s\" into repository \"%s\"", users, repositories)
}
Beispiel #2
0
func grantAccess(w http.ResponseWriter, r *http.Request) {
	repositories, users, err := accessParameters(r.Body)
	readOnly := r.URL.Query().Get("readonly") == "yes"
	if err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	if err := repository.GrantAccess(repositories, users, readOnly); err != nil {
		http.Error(w, err.Error(), http.StatusNotFound)
		return
	}
	if readOnly {
		fmt.Fprintf(w, "Successfully granted read-only access to users \"%s\" into repository \"%s\"", users, repositories)
	} else {
		fmt.Fprintf(w, "Successfully granted full access to users \"%s\" into repository \"%s\"", users, repositories)
	}
}