...

Source file src/github.com/grpc-ecosystem/grpc-gateway/v2/utilities/readerfactory.go

Documentation: github.com/grpc-ecosystem/grpc-gateway/v2/utilities

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

View as plain text