Documentation ¶
Overview ¶
Package web 通用的 web 开发框架
Index ¶
- Constants
- func NewConfigError(field string, msg any) *errs.ConfigError
- func NewLocaleError(format string, v ...any) error
- func NewStackError(err error) error
- type CTXSanitizer
- type ConfigError
- type Context
- type HandlerFunc
- type Job
- type JobFunc
- type LocaleStringer
- type Logger
- type Middleware
- type MiddlewareFunc
- type Options
- type QueryUnmarshaler
- type Responser
- type ResponserFunc
- type Router
- type Rule
- type Scheduler
- type Server
- type Service
- type ValidateFunc
- type Validation
- type Validator
Constants ¶
View Source
const ( // 特殊的值,当不想向用户展示 type 值时,该对象的 type 会被设置为该值。 ProblemAboutBlank = problems.ProblemAboutBlank // 400 ProblemBadRequest = problems.ProblemBadRequest ProblemPaymentRequired = problems.ProblemPaymentRequired ProblemForbidden = problems.ProblemForbidden ProblemNotFound = problems.ProblemNotFound ProblemMethodNotAllowed = problems.ProblemMethodNotAllowed ProblemNotAcceptable = problems.ProblemNotAcceptable ProblemProxyAuthRequired = problems.ProblemProxyAuthRequired ProblemRequestTimeout = problems.ProblemRequestTimeout ProblemConflict = problems.ProblemConflict ProblemGone = problems.ProblemGone ProblemLengthRequired = problems.ProblemLengthRequired ProblemPreconditionFailed = problems.ProblemPreconditionFailed ProblemRequestEntityTooLarge = problems.ProblemRequestEntityTooLarge ProblemRequestURITooLong = problems.ProblemRequestURITooLong ProblemUnsupportedMediaType = problems.ProblemUnsupportedMediaType ProblemRequestedRangeNotSatisfiable = problems.ProblemRequestedRangeNotSatisfiable ProblemExpectationFailed = problems.ProblemExpectationFailed ProblemTeapot = problems.ProblemTeapot ProblemMisdirectedRequest = problems.ProblemMisdirectedRequest ProblemUnprocessableEntity = problems.ProblemUnprocessableEntity ProblemLocked = problems.ProblemLocked ProblemFailedDependency = problems.ProblemFailedDependency ProblemTooEarly = problems.ProblemTooEarly ProblemUpgradeRequired = problems.ProblemUpgradeRequired ProblemPreconditionRequired = problems.ProblemPreconditionRequired ProblemTooManyRequests = problems.ProblemTooManyRequests ProblemRequestHeaderFieldsTooLarge = problems.ProblemRequestHeaderFieldsTooLarge // 500 ProblemInternalServerError = problems.ProblemInternalServerError ProblemNotImplemented = problems.ProblemNotImplemented ProblemBadGateway = problems.ProblemBadGateway ProblemGatewayTimeout = problems.ProblemGatewayTimeout ProblemHTTPVersionNotSupported = problems.ProblemHTTPVersionNotSupported ProblemVariantAlsoNegotiates = problems.ProblemVariantAlsoNegotiates ProblemInsufficientStorage = problems.ProblemInsufficientStorage ProblemLoopDetected = problems.ProblemLoopDetected ProblemNotExtended = problems.ProblemNotExtended ProblemNetworkAuthenticationRequired = problems.ProblemNetworkAuthenticationRequired )
预定义的 Problem id 值
View Source
const ( ServiceStopped = scheduled.Stopped // 停止状态,默认状态 ServiceRunning = scheduled.Running // 正在运行 ServiceFailed = scheduled.Failed // 出错,不再执行后续操作 )
服务的几种状态
View Source
const Version = "0.62.0"
Version 当前框架的版本
Variables ¶
This section is empty.
Functions ¶
func NewConfigError ¶ added in v0.61.0
func NewConfigError(field string, msg any) *errs.ConfigError
NewConfigError 返回表示配置文件错误的对象
field 表示错误的字段名; msg 表示错误信息,可以是任意类型,如果 msg 是 ConfigError 类型,那么此操作仅修改此类型的 Field 值;
func NewLocaleError ¶ added in v0.62.0
NewLocaleError 本地化的错误信息
func NewStackError ¶ added in v0.61.0
NewStackError 为 err 带上调用信息
Types ¶
type CTXSanitizer ¶ added in v0.38.0
type CTXSanitizer = server.CTXSanitizer
type ConfigError ¶ added in v0.42.0
type ConfigError = errs.ConfigError
type HandlerFunc ¶ added in v0.33.0
type HandlerFunc = server.HandlerFunc
type LocaleStringer ¶ added in v0.43.0
type LocaleStringer = localeutil.LocaleStringer
LocaleStringer 本地化字符串需要实在的接口
部分 error 返回可能也实现了该接口。
type Middleware ¶ added in v0.33.0
type Middleware = server.Middleware
type MiddlewareFunc ¶ added in v0.46.0
type MiddlewareFunc = server.MiddlewareFunc
type QueryUnmarshaler ¶ added in v0.58.0
type QueryUnmarshaler = query.Unmarshaler
QueryUnmarshaler 对查询参数的解析接口
type Responser ¶ added in v0.40.0
func Object ¶ added in v0.40.0
Object 输出状态和对象至客户端
body 表示需要输出的对象,该对象最终会被转换成相应的编码; kv 为报头,必须以偶数数量出现,奇数位为报头名,偶数位为对应的报头值;
type ResponserFunc ¶ added in v0.56.0
type ResponserFunc = server.ResponserFunc
type Rule ¶ added in v0.55.0
func NewRuleFunc ¶ added in v0.55.2
func NewRuleFunc(msg LocaleStringer, f func(any) bool) *Rule
NewRuleFunc 新建验证规则
type ValidateFunc ¶ added in v0.55.0
type ValidateFunc = server.ValidateFunc
type Validation ¶ added in v0.55.2
type Validation = server.Validation
Directories ¶
Path | Synopsis |
---|---|
Package app 为构建程序提供相对简便的方法
|
Package app 为构建程序提供相对简便的方法 |
cmd
|
|
web
Module
|
|
Package errs 与错误相关的定义
|
Package errs 与错误相关的定义 |
internal
|
|
encoding
Package encoding 处理 Accept-encoding 报头内容
|
Package encoding 处理 Accept-encoding 报头内容 |
files
Package files 配置文件管理
|
Package files 配置文件管理 |
header
Package header 与报头相关的处理方法
|
Package header 与报头相关的处理方法 |
mimetypes
Package mimetype 管理与 Mime type 相关的数据
|
Package mimetype 管理与 Mime type 相关的数据 |
problems
Package problems 提供对 Problem 相关内容的管理
|
Package problems 提供对 Problem 相关内容的管理 |
service
Package service 服务管理
|
Package service 服务管理 |
Package locales 为 web 包提供了本地化的内容
|
Package locales 为 web 包提供了本地化的内容 |
Package serializer 序列化的相关操作
|
Package serializer 序列化的相关操作 |
form
Package form 用于处理 www-form-urlencoded 编码
|
Package form 用于处理 www-form-urlencoded 编码 |
html
Package html 提供输出 HTML 内容的解码函数
|
Package html 提供输出 HTML 内容的解码函数 |
json
Package json JSON 格式的序列化方法
|
Package json JSON 格式的序列化方法 |
jsonp
Package jsonp JSONP 序列化操作
|
Package jsonp JSONP 序列化操作 |
xml
Package xml XML 编码的序列化操作
|
Package xml XML 编码的序列化操作 |
Package server 服务管理
|
Package server 服务管理 |
servertest
Package servertest 针对 server 的测试用例
|
Package servertest 针对 server 的测试用例 |
Click to show internal directories.
Click to hide internal directories.