apiutil

package
v0.56.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package apiutil provides utility functions for the API.

Index

Constants

This section is empty.

Variables

View Source
var ErrLimitedReaderLimitReached = errors.New("read limit reached")

ErrLimitedReaderLimitReached indicates that the read limit has been reached.

Functions

This section is empty.

Types

type LimitedReader

type LimitedReader struct {
	Count int64
	// contains filtered or unexported fields
}

LimitedReader reads from a reader up to a specific limit. When this limit has been reached, any subsequent read will return ErrLimitedReaderLimitReached. The underlying reader has to implement io.ReadCloser so that it can be used with http request bodies.

func NewLimitedReader

func NewLimitedReader(r io.ReadCloser, limit int64) *LimitedReader

NewLimitedReader creates a new LimitedReader.

func (*LimitedReader) Close

func (r *LimitedReader) Close() error

Close closes the underlying reader.

func (*LimitedReader) Read

func (r *LimitedReader) Read(buf []byte) (n int, err error)

Read reads from the underlying reader.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL