Пример #1
0
func Shared(res http.ResponseWriter, req *http.Request) {
	path := mux.Vars(req)["path"]
	res = info.SetCORS(res)
	if req.Method == "OPTIONS" {
		return
	}
	if _, ok := sharedFiles[path]; ok {
		log.Print("Serving file: " + path)
		http.ServeFile(res, req, info.Dir()+path)
	} else {
		log.Print("Blocking file: " + path)
		res.WriteHeader(404)
	}
}
Пример #2
0
//lists qualified files
func ListFiles(dir string) map[string]interface{} {
	fileObj := make(map[string]interface{})
	localDir := ""
	listRecursion(info.Dir(), localDir, fileObj)
	return fileObj
}
Пример #3
0
	"3gp":  "v",
	"avi":  "v",
	"mov":  "v",
	"mp4":  "v",
	"m4v":  "v",
	"m4a":  "a",
	"mp3":  "a",
	"mkv":  "v",
	"ogv":  "v",
	"ogm":  "v",
	"ogg":  "v",
	"oga":  "a",
	"webm": "v",
	"wav":  "a",
}
var sharedFiles = ListFiles(info.Dir())

func check(err error) {
	if err != nil {
		panic(err)
	}
}

func getItunes(name string) string {
	name = strings.Join(strings.Split(name, " "), "+")
	res, err := http.Get("https://itunes.apple.com/search?limit=1&term=" + name)
	if err != nil {
		return ""
	}
	body, err := ioutil.ReadAll(res.Body)
	resultObj := make(map[string]interface{})
Пример #4
0
func MainPage(res http.ResponseWriter, req *http.Request) {
	if !info.CheckAddr(req.RemoteAddr) {
		return
	}
	portal.MainPage(res, req, info.Dir(), info.Port(), verify, userid)
}