MCPcopy Create free account
hub / github.com/kataras/iris / loadFromBase

Method loadFromBase

_examples/file-server/basic/main_test.go:39–58  ·  view source on GitHub ↗
(dir string, strip string)

Source from the content-addressed store, hash-verified

37}
38
39func (r resource) loadFromBase(dir string, strip string) string {
40 filename := r.String()
41
42 filename = r.strip(strip)
43 if filepath.Ext(filename) == "" {
44 // root /.
45 filename = filename + "/index.html"
46 }
47
48 fullpath := filepath.Join(dir, filename)
49
50 b, err := os.ReadFile(fullpath)
51 if err != nil {
52 panic(fullpath + " failed with error: " + err.Error())
53 }
54
55 result := string(b)
56
57 return result
58}
59
60func TestFileServerBasic(t *testing.T) {
61 urls := []resource{

Callers 2

TestFileServerBasicFunction · 0.45
TestHandleDirDotFunction · 0.45

Calls 4

StringMethod · 0.95
stripMethod · 0.95
ExtMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected