FileResponder returns an HTTP response generator that returns the contents of the named file.
(filename string)
| 87 | // FileResponder returns an HTTP response generator that returns the |
| 88 | // contents of the named file. |
| 89 | func FileResponder(filename string) func() *http.Response { |
| 90 | return func() *http.Response { |
| 91 | f, err := os.Open(filename) |
| 92 | if err != nil { |
| 93 | return &http.Response{StatusCode: 404, Status: "404 Not Found", Body: types.EmptyBody} |
| 94 | } |
| 95 | return &http.Response{StatusCode: 200, Status: "200 OK", Body: f} |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // StaticResponder returns an HTTP response generator that parses res |
| 100 | // for an entire HTTP response, including headers and body. |