common WriteFile from resource fork
This commit is contained in:
parent
ac5da98149
commit
a641772159
22
http.go
22
http.go
|
@ -10,6 +10,7 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/lib/protobuf/httppb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -79,32 +80,13 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
if route == "/favicon.ico" {
|
||||
writeFile(w, "ipv6.png")
|
||||
httppb.WriteFile(w, resources, "ipv6.png")
|
||||
return
|
||||
}
|
||||
|
||||
log.Warn("BAD URL =", route)
|
||||
}
|
||||
|
||||
func writeFile(w http.ResponseWriter, filename string) {
|
||||
// fmt.Fprintln(w, "GOT TEST?")
|
||||
fullname := "resources/" + filename
|
||||
pfile, err := resources.ReadFile(fullname)
|
||||
if err != nil {
|
||||
log.Println("ERROR:", err)
|
||||
// w.Write(pfile)
|
||||
return
|
||||
}
|
||||
|
||||
var repohtml string
|
||||
repohtml = string(pfile)
|
||||
if filename == "goReference.svg" {
|
||||
w.Header().Set("Content-Type", "image/svg+xml")
|
||||
}
|
||||
fmt.Fprintln(w, repohtml)
|
||||
log.Println("writeFile() found internal file:", filename)
|
||||
}
|
||||
|
||||
// starts and sits waiting for HTTP requests
|
||||
func startHTTP() {
|
||||
http.HandleFunc("/", okHandler)
|
||||
|
|
Loading…
Reference in New Issue