|
@@ -18,6 +18,7 @@ func Router(c *movies.Collection) http.HandlerFunc {
|
18
|
18
|
movieHandler := Movie(c)
|
19
|
19
|
listHandler := List(c)
|
20
|
20
|
filesHandler := Files(c)
|
|
21
|
+ fileHandler := File(c, "/files/")
|
21
|
22
|
|
22
|
23
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
23
|
24
|
path := r.URL.Path
|
|
@@ -25,9 +26,6 @@ func Router(c *movies.Collection) http.HandlerFunc {
|
25
|
26
|
case path == "/":
|
26
|
27
|
homeHandler(w, r)
|
27
|
28
|
return
|
28
|
|
- case path == "/files":
|
29
|
|
- filesHandler(w, r)
|
30
|
|
- return
|
31
|
29
|
case path == "/style.css":
|
32
|
30
|
http.ServeFile(w, r, "templates/style.css")
|
33
|
31
|
return
|
|
@@ -37,6 +35,12 @@ func Router(c *movies.Collection) http.HandlerFunc {
|
37
|
35
|
case strings.HasPrefix(path, "/tt"):
|
38
|
36
|
movieHandler(w, r)
|
39
|
37
|
return
|
|
38
|
+ case path == "/files":
|
|
39
|
+ filesHandler(w, r)
|
|
40
|
+ return
|
|
41
|
+ case strings.HasPrefix(path, "/files/"):
|
|
42
|
+ fileHandler(w, r)
|
|
43
|
+ return
|
40
|
44
|
}
|
41
|
45
|
})
|
42
|
46
|
}
|
|
@@ -244,3 +248,11 @@ func Files(c *movies.Collection) http.HandlerFunc {
|
244
|
248
|
})
|
245
|
249
|
})
|
246
|
250
|
}
|
|
251
|
+
|
|
252
|
+func File(c *movies.Collection, prefix string) http.HandlerFunc {
|
|
253
|
+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
254
|
+ file := "/" + strings.TrimPrefix(r.URL.Path, prefix)
|
|
255
|
+
|
|
256
|
+ c.Files.Serve(w, r, file)
|
|
257
|
+ })
|
|
258
|
+}
|