Documentation ¶
Index ¶
- Variables
- func ParseBoundary(md metadata.MD) (string, error)
- func ProcessMultipartUpload(server uploadServer, f func(part *multipart.Part) error, sizeLimit int64) error
- func SaveMultipartFile(header *multipart.FileHeader, path string) error
- func ServeContent(server downloadServer, content io.ReadSeeker, contentType, name string, ...) error
- func ServeFile(server downloadServer, contentType, path string) error
- func WithFileForwardResponseOption() runtime.ServeMuxOption
- func WithFileIncomingHeaderMatcher() runtime.ServeMuxOption
- func WithHTTPBodyMarshaler() runtime.ServeMuxOption
- type FormData
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidRange = errors.New("invalid range") // ErrInvalidRange - invalid range ErrSizeLimitExceeded = errors.New("size limit exceeded") // ErrSizeLimitExceeded - message too large )
Functions ¶
func ParseBoundary ¶ added in v0.1.1
ParseBoundary parses the boundary parameter from the given metadata.
func ProcessMultipartUpload ¶ added in v0.1.1
func ProcessMultipartUpload(server uploadServer, f func(part *multipart.Part) error, sizeLimit int64) error
ProcessMultipartUpload processes the provided multipart upload. The provided function is called for each part. sizeLimit is the maximum size of the form data in bytes (0 = unlimited). Useful for forwarding multipart requests to another server without saving them locally or in memory.
func SaveMultipartFile ¶
func SaveMultipartFile(header *multipart.FileHeader, path string) error
SaveMultipartFile saves the provided multipart file to the given path.
func ServeContent ¶
func ServeContent( server downloadServer, content io.ReadSeeker, contentType, name string, modTime time.Time, size int64, ) error
ServeContent comes from http.ServeContent, and made some adaptations for DownloadServer
func WithFileForwardResponseOption ¶
func WithFileForwardResponseOption() runtime.ServeMuxOption
WithFileForwardResponseOption - forwardResponseOption is an option that will be called on the relevant context.Context, http.ResponseWriter, and proto.Message before every forwarded response.
func WithFileIncomingHeaderMatcher ¶
func WithFileIncomingHeaderMatcher() runtime.ServeMuxOption
WithFileIncomingHeaderMatcher returns a ServeMuxOption representing a headerMatcher for incoming request to gateway. This matcher will be called with each header in http.Request. If matcher returns true, that header will be passed to gRPC context. To transform the header before passing to gRPC context, matcher should return modified header.
func WithHTTPBodyMarshaler ¶
func WithHTTPBodyMarshaler() runtime.ServeMuxOption
WithHTTPBodyMarshaler returns a ServeMuxOption which associates inbound and outbound Marshalers to a MIME type in mux.
Types ¶
type FormData ¶
type FormData struct {
// contains filtered or unexported fields
}
FormData is a wrapper around multipart.Form.
func NewFormData ¶
NewFormData returns a new FormData. sizeLimit is the maximum size of the form data in bytes (0 = unlimited).
func (*FormData) Files ¶
func (f *FormData) Files(key string) []*multipart.FileHeader
Files returns the files for the provided form key
func (*FormData) FirstFile ¶
func (f *FormData) FirstFile(key string) *multipart.FileHeader
FirstFile returns the first file for the provided form key
func (*FormData) FirstValue ¶
FirstValue returns the first value for the provided form key