-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
handlerstest.go
86 lines (67 loc) · 2.24 KB
/
handlerstest.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
84
85
86
// +build debug
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func handlerMain(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./src/index.html")
}
func handlerJsBundle(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./build/bundle.js")
}
func handlerFaviconIco(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/favicon.ico")
}
func handlerBootstrapCSS(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/css/bootstrap.css")
}
func handlerLayout(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./build/layout.css")
}
func handlerFontAwesomeMinCSS(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/css/font-awesome.min.css")
}
func handlerFontsFaOTF(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/fonts/FontAwesome.otf")
}
func handlerFontsFaEOT(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/fonts/fontawesome-webfont.eot")
}
func handlerFontsFaSVG(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/fonts/fontawesome-webfont.svg")
}
func handlerFontsFaTTF(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/fonts/fontawesome-webfont.ttf")
}
func handlerFontsFaWOFF(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/fonts/fontawesome-webfont.woff")
}
func handlerFontsFaWOFF2(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/fonts/fontawesome-webfont.woff2")
}
func handlerSiriDBLargePNG(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/img/siridb-large.png")
}
func handlerSiriDBSmallPNG(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/img/siridb-small.png")
}
func handlerLoaderGIF(w http.ResponseWriter, r *http.Request) {
handleFileRequest(w, "./static/img/loader.gif")
}
func handleFileRequest(w http.ResponseWriter, fn string) {
b, err := ioutil.ReadFile(fn)
if err == nil {
_, err = w.Write(b)
} else {
w.WriteHeader(http.StatusInternalServerError)
_, err = fmt.Fprintf(w, "Internal server error: %s", err)
}
if err != nil {
fmt.Println(err)
}
}
func init() {
fmt.Println("DEBUG MODE: using original template files...")
}