コード例 #1
0
ファイル: server.go プロジェクト: danackerson/gotorrents
// TorrentHandler is now commented
func TorrentHandler(w http.ResponseWriter, req *http.Request, renderer *render.Render) {
	searchString := req.FormValue("search")
	log.Printf("Searching for %s", searchString)

	torrents := make(map[int][]string)
	torrents = SearchTorrentsFor(searchString, torrents)

	// prepare response page
	renderer.HTML(w, http.StatusOK, "content", torrents)
}
コード例 #2
0
ファイル: server.go プロジェクト: danackerson/gotorrents
// ListDownloadsHandler AJAX method is now commented
func ListDownloadsHandler(w http.ResponseWriter, req *http.Request, renderer *render.Render) {
	dir := req.FormValue("dir")

	if strings.HasPrefix(dir, "~") {
		homedir := os.Getenv("HOME")
		dir = homedir + dir[1:]
	}

	files := structures.PrepareDirectoryContents(dir)

	renderer.HTML(w, http.StatusOK, "downloadDirectory", files)
}
コード例 #3
0
ファイル: main.go プロジェクト: nubunto/streamr
func homeHandler(renderer *render.Render, data HomeDisplay) http.HandlerFunc {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		renderer.HTML(w, http.StatusOK, "home-template", data)
	})
}