func requestsHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Content-type", "application/javascript") switch r.Method { case "GET": fmt.Fprintf(w, toJSON(api.Requests())) case "DELETE": api.ClearRequests() fmt.Fprintf(w, toJSON(api.Requests())) } }
func unrequestHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Content-type", "application/javascript") hash := r.URL.Query().Get("hash") var hashes []string hashes = append(hashes, hash) api.Unrequest(hashes) fmt.Fprintf(w, toJSON(api.Requests())) }
func clearRequestsHandler(w http.ResponseWriter, r *http.Request) { w.Header().Set("Access-Control-Allow-Origin", "*") w.Header().Set("Content-type", "application/javascript") api.ClearRequests() fmt.Fprintf(w, toJSON(api.Requests())) }