base

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

This section is empty.

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
	APIEndpoint string
	UserAgent   string
}

func (*Base) GetJson

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

func (*Base) GetPb

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

func (*Base) Init

func (b *Base) Init() error

func (*Base) MakeRequest

func (b *Base) MakeRequest(method, path 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

Jump to

Keyboard shortcuts

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