statusCode

package
v0.0.0-...-5ed6f2c Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: MIT Imports: 0 Imported by: 0

README

错误状态码

通过API接口中的code字段,可以获取到当前请求的状态,判断请求是否成功或出现错误。

原文档地址: https://dev.qweather.com/docs/resource/status-code/

代码 说明
200 请求成功
204 请求成功,但你查询的地区暂时没有你需要的数据。
400 请求错误,可能包含错误的请求参数或缺少必选的请求参数。
401 认证失败,可能使用了错误的KEY、数字签名错误、KEY的类型错误(如使用SDK的KEY去访问Web API)。
402 超过访问次数或余额不足以支持继续访问服务,你可以充值、升级访问量或等待访问量重置。
403 无访问权限,可能是绑定的PackageName、BundleID、域名IP地址不一致,或者是需要额外付费的数据。
404 查询的数据或地区不存在。
429 超过限定的QPM(每分钟访问次数),请参考QPM说明
500 无响应或超时,接口服务异常请联系我们

最新的状态码与S6版本API不兼容,请参考S6版本的状态码

Documentation

Overview

Package statusCode 状态码

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSuccess

func IsSuccess(code Code) bool

func Translate

func Translate(code Code) string

Translate 翻译状态码

Types

type Code

type Code string
const (
	Success         Code = "200" // 请求成功
	DataNotExists   Code = "204" // 请求成功,但你查询的地区暂时没有你需要的数据。
	ParamError      Code = "400" // 请求错误,可能包含错误的请求参数或缺少必选的请求参数。
	AuthorizeFailed Code = "401" // 认证失败,可能使用了错误的KEY、数字签名(https://dev.qweather.com/docs/resource/signature-auth/)错误、KEY的类型错误(如使用SDK的KEY去访问Web API)。
	ExceedLimit     Code = "402" // 超过访问次数或余额不足以支持继续访问服务,你可以充值、升级访问量或等待访问量重置。
	NoPermission    Code = "403" // 无访问权限,可能是绑定的PackageName、BundleID、域名IP地址不一致,或者是需要额外付费的数据。
	NotFound        Code = "404" // 查询的数据或地区不存在。
	TooManyRequests Code = "429" // 超过限定的QPM(每分钟访问次数),请参考QPM说明(https://dev.qweather.com/docs/resource/glossary/#qpm)
	Timeout         Code = "500" // 无响应或超时,接口服务异常请联系我们(https://www.qweather.com/contact)
)

func (Code) IsSuccess

func (c Code) IsSuccess() bool

func (Code) Translate

func (c Code) Translate() string

Jump to

Keyboard shortcuts

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