common write file function
This commit is contained in:
parent
6077c54d22
commit
47cd147ca0
|
@ -0,0 +1,29 @@
|
||||||
|
// 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
|
||||||
|
}
|
Loading…
Reference in New Issue