qcdn

package module
v0.0.0-...-361ade7 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 8 Imported by: 0

README

qcdn simple proxy

Build Status Go Report Card Coverage Status GoDoc

初始化:

proxy := NewQcdnProxy(&QcdnConfig{
	Timeout: 0, // 请求的超时时间,0 代表不超时
})
proxy.SetStrategy("https://example-qcdn.com", &QcdnStrategy{
	Backup: "https://example-cdn.com", // 备份域名,主域名下载失败的时候启用
	Boot: "https://example-cdn.com", // 首开优化域名,在 MakeVodURL 传入非 0 的 bootLen 时启用
})

访问资源:

bootLen := 0 // 通过 Boot 域名先加载多少字节,传 0 表示不做首开优化
url := proxy.MakeVodURL("https://example-qcdn.com/video.mp4", bootLen)
...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QcdnConfig

type QcdnConfig struct {
	Timeout int // in ms
}

type QcdnProxy

type QcdnProxy struct {
	// contains filtered or unexported fields
}

func NewQcdnProxy

func NewQcdnProxy(conf *QcdnConfig) *QcdnProxy

func (*QcdnProxy) Close

func (p *QcdnProxy) Close()

func (*QcdnProxy) MakeVodURL

func (p *QcdnProxy) MakeVodURL(urlVod string, bootLen int) string

func (*QcdnProxy) SetStrategy

func (p *QcdnProxy) SetStrategy(urlBase_ string, s *QcdnStrategy)

type QcdnStrategy

type QcdnStrategy struct {
	Backup string
	Boot   string
}

Jump to

Keyboard shortcuts

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