blob: 6dd3854665f19522e87194ac824327f30d7fd2e5 [file] [log] [blame]
khenaidoo59ce9dd2019-11-11 13:05:32 -05001package utilities
2
3import (
4 "bytes"
5 "io"
6 "io/ioutil"
7)
8
9// IOReaderFactory takes in an io.Reader and returns a function that will allow you to create a new reader that begins
10// at the start of the stream
11func IOReaderFactory(r io.Reader) (func() io.Reader, error) {
12 b, err := ioutil.ReadAll(r)
13 if err != nil {
14 return nil, err
15 }
16
17 return func() io.Reader {
18 return bytes.NewReader(b)
19 }, nil
20}