Example #1
0
File: rest.go Project: andynu/rfk
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()))
	}
}
Example #2
0
File: rest.go Project: andynu/rfk
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()))
}
Example #3
0
File: rest.go Project: andynu/rfk
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()))
}