Documentation
¶
Index ¶
- Constants
- func AutoProxyURL(ctx *gin.Context, u, t string, headers map[string]string, ...) error
- func GetM3u8Target(token string) (*m3u8TargetClaims, error)
- func NewM3u8TargetToken(targetUrl, roomId, movieId string, isM3u8File bool) (string, error)
- func ParseContentRangeStartAndEnd(contentRange string) (int64, int64, error)
- func ParseContentRangeTotalLength(contentRange string) (int64, error)
- func ProxyM3u8(ctx *gin.Context, u string, headers map[string]string, isM3u8File bool, ...) error
- func ProxyURL(ctx *gin.Context, u string, headers map[string]string, opts ...ProxyURLOption) error
- type ByteRange
- type Cache
- type CacheItem
- type CacheMetadata
- type FileCache
- type FileCacheOption
- type Headers
- type HttpReadSeekCloser
- func (h *HttpReadSeekCloser) Close() error
- func (h *HttpReadSeekCloser) ContentLength() int64
- func (h *HttpReadSeekCloser) ContentTotalLength() (int64, error)
- func (h *HttpReadSeekCloser) ContentType() (string, error)
- func (h *HttpReadSeekCloser) FetchNextChunk() error
- func (h *HttpReadSeekCloser) Offset() int64
- func (h *HttpReadSeekCloser) Read(p []byte) (n int, err error)
- func (h *HttpReadSeekCloser) Seek(offset int64, whence int) (int64, error)
- type HttpReadSeekerConf
- func AllowedContentTypes(types ...string) HttpReadSeekerConf
- func WithClient(client *http.Client) HttpReadSeekerConf
- func WithContentTotalLength(contentTotalLength int64) HttpReadSeekerConf
- func WithContext(ctx context.Context) HttpReadSeekerConf
- func WithForceNotSupportRange(notSupportRange bool) HttpReadSeekerConf
- func WithHeadMethod(method string) HttpReadSeekerConf
- func WithHeaders(headers http.Header) HttpReadSeekerConf
- func WithHeadersMap(headers map[string]string) HttpReadSeekerConf
- func WithMethod(method string) HttpReadSeekerConf
- func WithNotSupportSeekWhenNotSupportRange(notSupportSeekWhenNotSupportRange bool) HttpReadSeekerConf
- func WithPerLength(length int64) HttpReadSeekerConf
- type MemoryCache
- type MemoryCacheOption
- type Proxy
- type ProxyURLOption
- type ProxyURLOptions
- type SliceCacheProxy
- type TrieNode
Constants ¶
const (
DefaultBufferSize = 16 * 1024
)
Variables ¶
This section is empty.
Functions ¶
func AutoProxyURL ¶ added in v0.7.6
func GetM3u8Target ¶
func NewM3u8TargetToken ¶
func ParseContentRangeStartAndEnd ¶ added in v0.7.7
func ParseContentRangeTotalLength ¶ added in v0.7.7
ParseContentRangeTotalLength parses a Content-Range header value and returns the total length
Types ¶
type ByteRange ¶ added in v0.7.7
ByteRange represents an HTTP Range header value
func ParseByteRange ¶ added in v0.7.7
ParseByteRange parses a Range header value in the format: bytes=<start>-<end> where end is optional
type Cache ¶ added in v0.7.7
type Cache interface { Get(key string) (*CacheItem, bool, error) GetAnyWithPrefix(prefix string) (*CacheItem, bool, error) Set(key string, data *CacheItem) error }
Cache defines the interface for cache implementations
type CacheItem ¶ added in v0.7.7
type CacheItem struct { Metadata *CacheMetadata Data []byte }
CacheItem represents a cached response with metadata and data
type CacheMetadata ¶ added in v0.7.7
type CacheMetadata struct { Headers http.Header `json:"h,omitempty"` ContentType string `json:"ct,omitempty"` ContentTotalLength int64 `json:"ctl,omitempty"` }
CacheMetadata stores metadata about a cached response
func (*CacheMetadata) MarshalBinary ¶ added in v0.7.7
func (m *CacheMetadata) MarshalBinary() ([]byte, error)
type FileCache ¶ added in v0.7.7
type FileCache struct {
// contains filtered or unexported fields
}
func NewFileCache ¶ added in v0.7.7
func NewFileCache(filePath string, opts ...FileCacheOption) *FileCache
func (*FileCache) GetAnyWithPrefix ¶ added in v0.7.8
type FileCacheOption ¶ added in v0.7.7
type FileCacheOption func(*FileCache)
func WithFileCacheMaxAge ¶ added in v0.7.7
func WithFileCacheMaxAge(age time.Duration) FileCacheOption
func WithFileCacheMaxSizeBytes ¶ added in v0.7.7
func WithFileCacheMaxSizeBytes(size int64) FileCacheOption
type HttpReadSeekCloser ¶ added in v0.7.7
type HttpReadSeekCloser struct {
// contains filtered or unexported fields
}
func NewHttpReadSeekCloser ¶ added in v0.7.7
func NewHttpReadSeekCloser(url string, conf ...HttpReadSeekerConf) *HttpReadSeekCloser
func (*HttpReadSeekCloser) Close ¶ added in v0.7.7
func (h *HttpReadSeekCloser) Close() error
func (*HttpReadSeekCloser) ContentLength ¶ added in v0.7.7
func (h *HttpReadSeekCloser) ContentLength() int64
func (*HttpReadSeekCloser) ContentTotalLength ¶ added in v0.7.7
func (h *HttpReadSeekCloser) ContentTotalLength() (int64, error)
func (*HttpReadSeekCloser) ContentType ¶ added in v0.7.7
func (h *HttpReadSeekCloser) ContentType() (string, error)
func (*HttpReadSeekCloser) FetchNextChunk ¶ added in v0.7.7
func (h *HttpReadSeekCloser) FetchNextChunk() error
func (*HttpReadSeekCloser) Offset ¶ added in v0.7.7
func (h *HttpReadSeekCloser) Offset() int64
type HttpReadSeekerConf ¶ added in v0.7.7
type HttpReadSeekerConf func(h *HttpReadSeekCloser)
func AllowedContentTypes ¶ added in v0.7.7
func AllowedContentTypes(types ...string) HttpReadSeekerConf
func WithClient ¶ added in v0.7.7
func WithClient(client *http.Client) HttpReadSeekerConf
func WithContentTotalLength ¶ added in v0.7.8
func WithContentTotalLength(contentTotalLength int64) HttpReadSeekerConf
func WithContext ¶ added in v0.7.7
func WithContext(ctx context.Context) HttpReadSeekerConf
func WithForceNotSupportRange ¶ added in v0.7.9
func WithForceNotSupportRange(notSupportRange bool) HttpReadSeekerConf
func WithHeadMethod ¶ added in v0.7.7
func WithHeadMethod(method string) HttpReadSeekerConf
func WithHeaders ¶ added in v0.7.7
func WithHeaders(headers http.Header) HttpReadSeekerConf
func WithHeadersMap ¶ added in v0.7.7
func WithHeadersMap(headers map[string]string) HttpReadSeekerConf
func WithMethod ¶ added in v0.7.7
func WithMethod(method string) HttpReadSeekerConf
func WithNotSupportSeekWhenNotSupportRange ¶ added in v0.7.9
func WithNotSupportSeekWhenNotSupportRange(notSupportSeekWhenNotSupportRange bool) HttpReadSeekerConf
func WithPerLength ¶ added in v0.7.9
func WithPerLength(length int64) HttpReadSeekerConf
sets the per length of the request
type MemoryCache ¶ added in v0.7.7
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements an in-memory Cache with LRU eviction
func NewMemoryCache ¶ added in v0.7.7
func NewMemoryCache(capacity int, opts ...MemoryCacheOption) *MemoryCache
func (*MemoryCache) Get ¶ added in v0.7.7
func (c *MemoryCache) Get(key string) (*CacheItem, bool, error)
func (*MemoryCache) GetAnyWithPrefix ¶ added in v0.7.8
func (c *MemoryCache) GetAnyWithPrefix(prefix string) (*CacheItem, bool, error)
type MemoryCacheOption ¶ added in v0.7.7
type MemoryCacheOption func(*MemoryCache)
func WithMaxSizeBytes ¶ added in v0.7.7
func WithMaxSizeBytes(size int64) MemoryCacheOption
type Proxy ¶ added in v0.7.7
type Proxy interface { io.ReadSeeker ContentTotalLength() (int64, error) ContentType() (string, error) }
Proxy defines the interface for proxy implementations
type ProxyURLOption ¶ added in v0.7.8
type ProxyURLOption func(o *ProxyURLOptions)
func WithProxyURLCache ¶ added in v0.7.8
func WithProxyURLCache(cache bool) ProxyURLOption
func WithProxyURLCacheKey ¶ added in v0.7.8
func WithProxyURLCacheKey(key string) ProxyURLOption
type ProxyURLOptions ¶ added in v0.7.8
func NewProxyURLOptions ¶ added in v0.7.8
func NewProxyURLOptions(opts ...ProxyURLOption) *ProxyURLOptions
type SliceCacheProxy ¶ added in v0.7.7
type SliceCacheProxy struct {
// contains filtered or unexported fields
}
SliceCacheProxy implements caching of content slices
func NewSliceCacheProxy ¶ added in v0.7.7
func NewSliceCacheProxy(key string, sliceSize int64, r Proxy, cache Cache) *SliceCacheProxy
NewSliceCacheProxy creates a new SliceCacheProxy instance
func (*SliceCacheProxy) Proxy ¶ added in v0.7.7
func (c *SliceCacheProxy) Proxy(w http.ResponseWriter, r *http.Request) error
func (*SliceCacheProxy) ServeHTTP ¶ added in v0.7.7
func (c *SliceCacheProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP implements http.Handler interface
type TrieNode ¶ added in v0.7.8
type TrieNode struct {
// contains filtered or unexported fields
}
TrieNode represents a node in the prefix tree
func NewTrieNode ¶ added in v0.7.8
func NewTrieNode() *TrieNode