-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
83 lines (63 loc) · 1.26 KB
/
routes.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package main
import (
"fmt"
"net/http"
"strings"
)
// Item ... Directory item.
type Item struct {
Name string
Type string
}
func cdUp(w http.ResponseWriter, r *http.Request) {
splitUp := strings.Split(Current, "/")
Current = strings.Join(splitUp[:len(splitUp)-1], "/")
dir := read()
writeJSON(w, &dir)
}
/*
func index(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)
return
}
t, err := template.ParseFiles("views/index.gohtml")
if err != nil {
return
}
t.Execute(w, nil)
return
}
*/
func initial(w http.ResponseWriter, r *http.Request) {
Current = Init
dir := read()
writeJSON(w, &dir)
}
func next(w http.ResponseWriter, r *http.Request) {
afNext()
writeJSON(w, nil)
}
func play(w http.ResponseWriter, r *http.Request) {
thing := r.URL.Query()["item"][0]
fullPath := Current + "/" + thing
afKill()
afPlay(fullPath)
writeJSON(w, nil)
}
func playdir(w http.ResponseWriter, r *http.Request) {
afKill()
afPlay(Current)
writeJSON(w, nil)
}
func readDir(w http.ResponseWriter, r *http.Request) {
thing := r.URL.Query()["item"][0]
fmt.Println(thing)
Current = Current + "/" + thing
dir := read()
writeJSON(w, &dir)
}
func stop(w http.ResponseWriter, r *http.Request) {
afKill()
writeJSON(w, nil)
}