forked from asjoyner/fuse_gdrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status_pages.go
55 lines (47 loc) · 1.15 KB
/
status_pages.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main
import (
"fmt"
"net/http"
"google.golang.org/api/drive/v2"
)
type FilesPage struct {
files []*drive.File
}
func (t FilesPage) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain")
for _, f := range t.files {
fmt.Fprintf(w, "%+v %+v\n Parents: ", f.Title, f.Id)
for _, p := range f.Parents {
fmt.Fprintf(w, "%+v ", p.Id)
}
fmt.Fprintf(w, "\n")
}
}
/*
type TreePage struct {
tree Node
}
func (n Node) PrintChildren(w http.ResponseWriter, depth int) {
indent := ""
for i := 0; i < depth; i++ {
indent += " "
}
fmt.Fprintf(w, "%+v\n", n.Title)
for _, c := range n.Children {
c.PrintChildren(w, depth+1)
}
}
func (t TreePage) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "text/plain")
t.tree.PrintChildren(w, 0)
}
*/
func RootHandler(w http.ResponseWriter, req *http.Request) {
// The "/" pattern matches everything, so we need to check
// that we're at the root here.
if req.URL.Path != "/" {
http.NotFound(w, req)
return
}
fmt.Fprintln(w, "<html><body>Check out the <a href=/files>files</a> and <a href=/tree>tree</a> pages!")
}