-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.go
76 lines (63 loc) · 1.39 KB
/
file.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
package main
import (
"net/http"
"strings"
"time"
)
func staticHandeler(w http.ResponseWriter, r *http.Request) {
dur := time.Now()
v := strings.Split(r.URL.Path[1:], "/")
if len(v) < 2 {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte("no file"))
printStat(r, dur, "err")
return
}
if v[1] == "fonts" {
if len(v) < 3 || len(v) > 3 {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte("no file"))
printStat(r, dur, "err")
return
}
switch v[2] {
case "arabic":
http.ServeFile(w, r, StaticDir+"/assets/UthmanicHafs1Ver18.woff2")
printStat(r, dur, "file")
return
case "english":
http.ServeFile(w, r, StaticDir+"/assets/Lato-Regular.ttf")
printStat(r, dur, "file")
return
case "bangla":
http.ServeFile(w, r, StaticDir+"/assets/SolaimanLipi.ttf")
printStat(r, dur, "file")
return
default:
w.Write([]byte("no file found"))
printStat(r, dur, "err")
return
}
}
if v[1] == "images" {
if len(v) < 3 || len(v) > 3 {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte("no file"))
return
}
switch v[2] {
case "favicon":
http.ServeFile(w, r, StaticDir+"/assets/quran-faviocn.png")
printStat(r, dur, "file")
return
case "quran.png":
http.ServeFile(w, r, StaticDir+"/assets/quran.png")
printStat(r, dur, "file")
return
default:
w.Write([]byte("no file found"))
printStat(r, dur, "err")
return
}
}
}