summaryrefslogtreecommitdiff
path: root/writefile.go
blob: acf672bcab55056d1f26c86604a2d73532b688b6 (plain)
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
// 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
}