aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--assets/favicon.icobin0 -> 5430 bytes
-rw-r--r--gopherproxy.go18
2 files changed, 18 insertions, 0 deletions
diff --git a/assets/favicon.ico b/assets/favicon.ico
new file mode 100644
index 0000000..b6d0998
--- /dev/null
+++ b/assets/favicon.ico
Binary files differ
diff --git a/gopherproxy.go b/gopherproxy.go
index b65418d..f034cb9 100644
--- a/gopherproxy.go
+++ b/gopherproxy.go
@@ -166,6 +166,18 @@ func RobotsTxtHandler(robotstxtdata []byte) http.HandlerFunc {
166 } 166 }
167} 167}
168 168
169func FaviconHandler(favicondata []byte) http.HandlerFunc {
170 return func(w http.ResponseWriter, req *http.Request) {
171 if favicondata == nil {
172 http.Error(w, "Not Found", http.StatusNotFound)
173 return
174 }
175
176 w.Header().Set("Content-Type", "image/vnd.microsoft.icon")
177 w.Write(favicondata)
178 }
179}
180
169func FontHandler(woff2 bool, fontdata []byte) http.HandlerFunc { 181func FontHandler(woff2 bool, fontdata []byte) http.HandlerFunc {
170 return func(w http.ResponseWriter, req *http.Request) { 182 return func(w http.ResponseWriter, req *http.Request) {
171 if fontdata == nil { 183 if fontdata == nil {
@@ -225,6 +237,11 @@ func ListenAndServe(bind, robotsfile, uri string) error {
225 styletext = "" 237 styletext = ""
226 } 238 }
227 239
240 favicondata, err := box.Find("favicon.ico")
241 if err != nil {
242 favicondata = []byte{}
243 }
244
228 tpldata, err := ioutil.ReadFile(".template") 245 tpldata, err := ioutil.ReadFile(".template")
229 if err == nil { 246 if err == nil {
230 tpltext = string(tpldata) 247 tpltext = string(tpldata)
@@ -246,6 +263,7 @@ func ListenAndServe(bind, robotsfile, uri string) error {
246 263
247 http.HandleFunc("/", GopherHandler(tpl, robotsdata, styletext, uri)) 264 http.HandleFunc("/", GopherHandler(tpl, robotsdata, styletext, uri))
248 http.HandleFunc("/robots.txt", RobotsTxtHandler(robotstxtdata)) 265 http.HandleFunc("/robots.txt", RobotsTxtHandler(robotstxtdata))
266 http.HandleFunc("/favicon.ico", FaviconHandler(favicondata))
249 http.HandleFunc("/iosevka-term-ss03-regular.woff", FontHandler(false, fontdataw)) 267 http.HandleFunc("/iosevka-term-ss03-regular.woff", FontHandler(false, fontdataw))
250 http.HandleFunc("/iosevka-term-ss03-regular.woff2", FontHandler(true, fontdataw2)) 268 http.HandleFunc("/iosevka-term-ss03-regular.woff2", FontHandler(true, fontdataw2))
251 //http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets/")))) 269 //http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets/"))))