Beispiel #1
0
func Handler(c *blobserv.Client, w http.ResponseWriter, r *http.Request) {
	defer util.DeferWrite(w)

	pth := strings.Trim(r.URL.Path, "/")
	if pth == "fupload" {
		err := util.LoadStatic(appserv.Static("fupload/index.html"), w)
		util.Check(err)
	} else if pth == "fupload/putfiles" {
		putfiles(c, w, r)
	} else {
		err := util.LoadStatic(appserv.Static(pth), w)
		util.Check(err)
	}
}
Beispiel #2
0
func Handler(nc *blobserv.Client, w http.ResponseWriter, r *http.Request) {
	defer util.DeferWrite(w)
	c = nc

	tmpl := template.Must(template.ParseFiles(appserv.Static("pics/index.tmpl")))

	if picIndex == nil {
		loadPicIndex()
	}
	updateIndex()

	pth := strings.Trim(r.URL.Path, "/")
	if pth == "pics" {
		links := picLinks(picIndex.Newest(10))
		err := tmpl.Execute(w, links)
		util.Check(err)
	} else if strings.HasPrefix(pth, "pics/ref/") {
		ref := path.Base(pth)
		ref = ref[:len(ref)-len(path.Ext(ref))]

		fblob, err := c.ObjectTip(ref)
		util.Check(err)

		m, data, err := c.ReconstituteFile(fblob.Ref())
		util.Check(err)

		ext := path.Ext(m.Name)
		w.Header().Set("Content-Type", mime.TypeByExtension(ext))
		w.Write(data)
	} else {
		err := util.LoadStatic(appserv.Static(pth), w)
		util.Check(err)
	}
}
Beispiel #3
0
func Handler(c *blobserv.Client, w http.ResponseWriter, r *http.Request) {
	defer util.DeferWrite(w)

	tmpl := template.Must(template.ParseFiles(appserv.Static("recent/index.tmpl")))

	pth := strings.Trim(r.URL.Path, "/")
	if pth == "recent" {
		data := stripBlobs(c)
		err := tmpl.Execute(w, data)
		util.Check(err)
	} else {
		err := util.LoadStatic(appserv.Static(pth), w)
		util.Check(err)
	}
}