MCPcopy
hub / github.com/perkeep/perkeep / FileResponder

Function FileResponder

internal/httputil/faketransport.go:89–97  ·  view source on GitHub ↗

FileResponder returns an HTTP response generator that returns the contents of the named file.

(filename string)

Source from the content-addressed store, hash-verified

87// FileResponder returns an HTTP response generator that returns the
88// contents of the named file.
89func 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.

Callers 12

TestGetUserIDFunction · 0.92
TestIntegrationRunFunction · 0.92
MakeTestDataMethod · 0.92
MakeTestDataMethod · 0.92
TestGetUserIdFunction · 0.92
TestIntegrationRunFunction · 0.92
TestGetUserIdFunction · 0.92
TestImportAlbumsFunction · 0.92
MakeTestDataMethod · 0.92
MakeTestDataMethod · 0.92
TestIntegrationRunFunction · 0.92
TestIntegrationFunction · 0.92

Calls 1

OpenMethod · 0.65

Tested by 8

TestGetUserIDFunction · 0.74
TestIntegrationRunFunction · 0.74
TestGetUserIdFunction · 0.74
TestIntegrationRunFunction · 0.74
TestGetUserIdFunction · 0.74
TestImportAlbumsFunction · 0.74
TestIntegrationRunFunction · 0.74
TestIntegrationFunction · 0.74