base

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	APIEndpoint     = "https://api.bilibili.com"
	APILiveEndpoint = "https://api.live.bilibili.com"
	DefaultUA       = "" /* 132-byte string literal not displayed */
)

Functions

func ErrorMmsg

func ErrorMmsg(code int) string

func IsHttpNOK

func IsHttpNOK(err error, code int) bool

Types

type APIResponse

type APIResponse struct {
	Code    int              `json:"code"`
	Message string           `json:"message"`
	TTL     int              `json:"ttl"`
	Data    *json.RawMessage `json:"data"`
}

type Base

type Base struct {
	Client    *http.Client
	Log       BaseLogger
	UserAgent string
}

func (*Base) GetJson

func (b *Base) GetJson(url string, opt interface{}, result interface{}) error

func (*Base) GetPb

func (b *Base) GetPb(url string, opt interface{}, result protoreflect.ProtoMessage) error

func (*Base) Init

func (b *Base) Init() error

func (*Base) MakeRequest

func (b *Base) MakeRequest(method, url string, opt interface{}, body []byte) (*http.Response, error)

func (*Base) Post

func (b *Base) Post(path string, values url.Values, body []byte, result interface{}) error

type BaseLogger

type BaseLogger interface {
	Println(v ...interface{})
	Printf(format string, v ...interface{})
}

type HttpNOK

type HttpNOK struct {
	StatusCode int
	Status     string
	Body       []byte
}

func GetHttpNOK

func GetHttpNOK(err error) *HttpNOK

func NewHttpNOK

func NewHttpNOK(resp *http.Response) *HttpNOK

func (*HttpNOK) Error

func (h *HttpNOK) Error() string

type NoLogger added in v0.2.0

type NoLogger struct{}

func (NoLogger) Printf added in v0.2.0

func (l NoLogger) Printf(format string, v ...interface{})

func (NoLogger) Println added in v0.2.0

func (l NoLogger) Println(v ...interface{})

Jump to

Keyboard shortcuts

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