(dir string, strip string)
| 37 | } |
| 38 | |
| 39 | func (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 | |
| 60 | func TestFileServerBasic(t *testing.T) { |
| 61 | urls := []resource{ |
no test coverage detected