示例#1
0
文件: rest.go 项目: 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()))
	}
}
示例#2
0
文件: rest.go 项目: 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()))
}
示例#3
0
文件: rest.go 项目: 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()))
}