MCPcopy Index your code
hub / github.com/screego/server / serveFile

Function serveFile

ui/serve.go:29–44  ·  view source on GitHub ↗
(name, contentType string)

Source from the content-addressed store, hash-verified

27}
28
29func serveFile(name, contentType string) http.HandlerFunc {
30 file, err := files.Open(name)
31 if err != nil {
32 log.Panic().Err(err).Msgf("could not find %s", file)
33 }
34 defer file.Close()
35 content, err := io.ReadAll(file)
36 if err != nil {
37 log.Panic().Err(err).Msgf("could not read %s", file)
38 }
39
40 return func(writer http.ResponseWriter, reg *http.Request) {
41 writer.Header().Set("Content-Type", contentType)
42 _, _ = writer.Write(content)
43 }
44}

Callers 1

RegisterFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected