http

package
v0.0.0-...-a6b6bab Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: Apache-2.0 Imports: 20 Imported by: 6

Documentation

Overview

Package http @Link https://gitee.com/linngc/central-mirror @Copyright Copyright (c) 2022 webos CLI @Author linngc @License

Package http @Link https://gitee.com/linngc/central-mirror @Copyright Copyright (c) 2022 central CLI @Author linngc @License

Package internal @Link https://gitee.com/linngc/central-mirror @Copyright Copyright (c) 2022 central CLI @Author linngc @License

Index

Constants

This section is empty.

Variables

View Source
var (
	CityMap = make(map[string]WeatherCity)
)

Functions

func AppendUri

func AppendUri(ctx context.Context, remote string, modelPath string) string

AppendUri 拼接URL路径

func CheckUriVerify

func CheckUriVerify(uris []string) map[string]bool

CheckUriVerify 检查网址是否合法

func GetCityByIp

func GetCityByIp(ip string) string

GetCityByIp 获取ip所属城市

func GetClientIp

func GetClientIp(ctx context.Context) string

GetClientIp 获取客户端IP

func GetDomain

func GetDomain(src string) string

GetDomain 获取域名信息 @Param src "https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/"

func GetDomainByCtx

func GetDomainByCtx(ctx context.Context) string

GetDomainByCtx 获取当前请求接口域名

func GetLocalIP

func GetLocalIP() (ip string, err error)

GetLocalIP 服务端ip

func GetRemote

func GetRemote(ctx context.Context, remote string, modelPath string) *http.Response

GetRemote 请求http数据

func GetReqClientIp

func GetReqClientIp(r *ghttp.Request) string

GetReqClientIp 获取客户端IP

func GetUserAgent

func GetUserAgent(ctx context.Context) string

GetUserAgent 获取user-agent

func NewReadSeeker

func NewReadSeeker(readSeeker io.ReadSeeker, limiter *rate.Limiter) io.ReadSeeker

func NewReader

func NewReader(reader io.Reader, limiter *rate.Limiter) io.Reader

func NewSpeedLimiter

func NewSpeedLimiter(speed float64) *rate.Limiter

func Pings

func Pings(ctx context.Context, remote string) (res map[string]int)

Pings 验证请求地址是否可用

func SpeedResponse

func SpeedResponse(resp http.ResponseWriter, req *http.Request, filePath string, speed float64) error

SpeedResponse 服务端文件传输限速

Types

type HttpTime

type HttpTime struct {
	DnsTime      time.Duration `json:"dnsTime"   dc:"dns响应时间"`
	ConnectTime  time.Duration `json:"connectTime"   dc:"链接时间"`
	ResponseTime time.Duration `json:"responseTime"   dc:"请求响应时间"`
	TotalTime    time.Duration `json:"totalTime"   dc:"总耗时"`
}

HttpTime 请求到响应花费的时间

func CheckUriTime

func CheckUriTime(url string) *HttpTime

CheckUriTime 获取请求到响应花费的时间

type ReadSeeker

type ReadSeeker struct {
	io.ReadSeeker
	// contains filtered or unexported fields
}

func (ReadSeeker) Read

func (rs ReadSeeker) Read(p []byte) (int, error)

type Reader

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

func (*Reader) Read

func (reader *Reader) Read(buf []byte) (int, error)

type Weather

type Weather struct {
	Data WeatherDay
}

type WeatherCity

type WeatherCity struct {
	Id       string `json:"id"  dc:"Id"`
	Pid      string `json:"pid"  dc:"父ID"`
	CityCode string `json:"cityCode"  dc:"城市ID"`
	CityName string `json:"cityName"  dc:"城市名称"`
}

WeatherCity 所有城市名称对应的数据

type WeatherDay

type WeatherDay struct {
	City    string `json:"city"  dc:"城市名称"`
	CityId  string `json:"cityId"  dc:"城市编号"`
	Temp    string `json:"temp"  dc:"Temp"`
	WD      string `json:"wd"  dc:"温度"`
	WS      string `json:"ws"  dc:"Id"`
	AP      string `json:"ap"  dc:"气压"`
	SD      string `json:"sd"  dc:"湿度"`
	WSE     string `json:"wse"  dc:"风速"`
	Time    string `json:"time"  dc:"时间"`
	IsRadar string `json:"isRadar"  dc:"IsRadar"`
	Radar   string `json:"radar"  dc:"雷达"`
}

WeatherDay 天气信息

Jump to

Keyboard shortcuts

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