30 lines
591 B
Go
30 lines
591 B
Go
// Copyright 1994-2025 WIT.COM Inc Licensed GPL 3.0
|
|
|
|
package httppb
|
|
|
|
import (
|
|
"embed"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
func WriteFile(w http.ResponseWriter, resfork embed.FS, filename string) error {
|
|
// fmt.Fprintln(w, "GOT TEST?")
|
|
fullname := "resources/" + filename
|
|
pfile, err := resfork.ReadFile(fullname)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
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)
|
|
return nil
|
|
}
|