Beispiel #1
0
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()))
	}
}
Beispiel #2
0
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()))
}
Beispiel #3
0
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()))
}