This commit is contained in:
1 parent
624093773b
commit
568e516b1a
18 files changed
+912
-80
No files matched your search
+24
-1
@@ -36,12 +36,15 @@ go mod tidy
|
|||||||
| `redis` | 原生 Redis 客户端创建与探测 | 应用装配根 |
|
| `redis` | 原生 Redis 客户端创建与探测 | 应用装配根 |
|
||||||
| `redis/commandlog` | 官方 Hook 与 Pipeline 执行观测 | 自建原生 Redis 的可选日志适配 |
|
| `redis/commandlog` | 官方 Hook 与 Pipeline 执行观测 | 自建原生 Redis 的可选日志适配 |
|
||||||
| `http` | Gin Server、Form/Meta、响应、可信注入、健康检查、合作式预算、OpenAPI 契约与排空 | HTTP 入口 |
|
| `http` | Gin Server、Form/Meta、响应、可信注入、健康检查、合作式预算、OpenAPI 契约与排空 | HTTP 入口 |
|
||||||
|
| `http/cors` | 来源匹配、凭据、预检、Vary 和显式授权回调 | HTTP 启动期可选中间件 |
|
||||||
|
| `http/scalar` | 内嵌 Scalar 页面与脚本 | 文档展示的可选包 |
|
||||||
|
| `ratelimit` | 内存/Redis 额度执行及重置 | 应用创建执行器,提供 Key 与额度 |
|
||||||
| `http/pprof` | 显式分析路由、默认回环限制与认证替换 | HTTP 启动期可选装配 |
|
| `http/pprof` | 显式分析路由、默认回环限制与认证替换 | HTTP 启动期可选装配 |
|
||||||
| `http/request` | URI/Query/Body、multipart、正文限制、Context 校验与字段级提示 | 自定义请求适配 |
|
| `http/request` | URI/Query/Body、multipart、正文限制、Context 校验与字段级提示 | 自定义请求适配 |
|
||||||
| `httpclient` | 出站连接池、请求编码、有界响应、原生流式与安全流水 | 第三方服务适配 |
|
| `httpclient` | 出站连接池、请求编码、有界响应、原生流式与安全流水 | 第三方服务适配 |
|
||||||
<!-- capabilities:end -->
|
<!-- capabilities:end -->
|
||||||
|
|
||||||
库不承载业务认证、权限、用户/管理员模型、数据库审计表、缓存 Key、锁、队列和供应商成功码。支持 OpenAPI 契约导出;CORS、请求限流、Scalar/Swagger UI 展示当前没有内置装配能力;pprof 通过可选的 `http/pprof` 子包显式注册。
|
库不承载业务认证、权限、用户/管理员模型、数据库审计表、缓存 Key、锁、队列和供应商成功码。支持 OpenAPI 契约导出;CORS、Scalar 和 pprof 通过可选子包显式接入;ratelimit 只提供额度执行,不推导业务 Key、身份、路由或 429 响应。未提供 Swagger UI、缓存或队列框架。
|
||||||
|
|
||||||
## 3. 最小 HTTP 服务
|
## 3. 最小 HTTP 服务
|
||||||
|
|
||||||
@@ -244,6 +247,20 @@ go run ./examples/openapi -out /tmp/ginframework-openapi.json
|
|||||||
|
|
||||||
普通 http 包不导入此子包,因此不会隐式加载分析 Handler。此子包依赖标准库 net/http/pprof;该标准库有向 DefaultServeMux 注册路由的 init 行为。框架自身使用独立 Gin 路由,不使用 DefaultServeMux 提供服务;应用若另行启动 DefaultServeMux,须按该服务自身的访问边界管理。
|
普通 http 包不导入此子包,因此不会隐式加载分析 Handler。此子包依赖标准库 net/http/pprof;该标准库有向 DefaultServeMux 注册路由的 init 行为。框架自身使用独立 Gin 路由,不使用 DefaultServeMux 提供服务;应用若另行启动 DefaultServeMux,须按该服务自身的访问边界管理。
|
||||||
|
|
||||||
|
### 5.6 CORS 协议与应用授权
|
||||||
|
|
||||||
|
导入 http/cors,调用 cors.New(cfg, options) 得到 (gin.HandlerFunc, error),构造失败不 panic。cfg 是纯数据,New 复制所有名单;Options.AllowOrigin 是静态来源不匹配时的动态授权回调,Options.OnOriginDenied 可输出业务拒绝协议,框架始终 Abort。回调只输出拒绝响应,不调用 Next;未提供时直接返回 403。来源白名单、扩展注册和数据库配置读取归应用。
|
||||||
|
|
||||||
|
Config 支持 AllowOrigins、AllowAllOrigins、AllowMethods、AllowHeaders、ExposeHeaders、AllowCredentials、AllowWildcard、CheckActualMethod 和 MaxAge。DefaultConfig 提供标准方法、基础头和十二小时缓存,但仍必须显式声明来源。New 不隐式扩展名单,零 MaxAge 不缓存,负值拒绝。静态来源接受 HTTP/HTTPS origin;单星号必须显式启用 AllowWildcard,其他可信 scheme 通过动态回调验证。凭据模式禁止星号 Origin,必须回显实际来源;方法/请求头的星号在凭据模式按预检请求回显。Vary 与既有响应合并。
|
||||||
|
|
||||||
|
默认只按方法名单校验预检;CheckActualMethod=true 时也限制实际跨域方法。无 Origin 或同源请求不做 CORS 协商。预检成功返回 204 且不进入业务处理链,来源/方法/头不通过则拒绝。应用要记录预检业务状态时可在外层中间件处理,不向库传入业务上下文常量。
|
||||||
|
|
||||||
|
### 5.7 可选 Scalar 展示
|
||||||
|
|
||||||
|
导入 http/scalar,使用 scalar.New(title, baseURI).Handler() 提供内嵌 index.html 与 api-reference.js。Handler 从 Gin 的 any 路径参数读取资源名,例如在 {baseURI}/*any 路由中调用。页面指向 {baseURI}/doc.json;OpenAPI 字节的生成、发布及文档权限由应用提供。标题和路径经过 HTML 转义,未知资源及路径穿越返回 404,不加载运行时 CDN 脚本。
|
||||||
|
|
||||||
|
Scalar 脚本约 3 MiB,只有导入此包的消费者才会包含这些资源;普通 http、CORS 和 pprof 不依赖该包。库不提供主题注册、前端构建或动态资产下载。
|
||||||
|
|
||||||
## 6. 配置、日志与诊断
|
## 6. 配置、日志与诊断
|
||||||
|
|
||||||
### 6.1 配置
|
### 6.1 配置
|
||||||
@@ -332,6 +349,12 @@ DialTimeoutMS/ReadTimeoutMS/WriteTimeoutMS、连接寿命和池超时的普通
|
|||||||
|
|
||||||
实例校验、认证、缓存 Key、锁和队列归应用;不要建立运行时动态注册中心或把多个实例当作一个事务。
|
实例校验、认证、缓存 Key、锁和队列归应用;不要建立运行时动态注册中心或把多个实例当作一个事务。
|
||||||
|
|
||||||
|
### 7.4 限流执行器
|
||||||
|
|
||||||
|
ratelimit.NewMemory() 创建入口独占的内存令牌桶;ratelimit.NewRedis(client) 借用已创建的原生 Redis,既不建池也不关闭客户端。ratelimit.Disabled{} 是明确禁用的实现。共同实现 Limiter 的 AllowN(ctx, *Config, count) 和 Reset(ctx, *Config),返回额度判定及保留原始原因的错误;协议拒绝、失败放行/关闭、Key、主体、前缀及总额度均由消费应用决定。Redis 取消传入真实调用,库不附加重试策略。
|
||||||
|
|
||||||
|
Config 的 Key、Total、Rate、TimeInterval 保持既有执行约定:内存 Rate 为每秒补充数,TimeInterval 不参与;Redis Rate 为每 TimeInterval 秒补充数、Total 为突发容量,非正 Total/Rate 沿用禁用额度判定。切换后端须按应用配置核对周期语义,不假定两算法可无条件互换。内存相同 Key 首次策略持续到 Reset,额度表不跨执行器共享、不建立后台淘汰任务;业务控制 Key 数量和需要重置的时机。库不保存业务名单或动态实例注册表。
|
||||||
|
|
||||||
## 8. 出站 HTTP Client
|
## 8. 出站 HTTP Client
|
||||||
|
|
||||||
同一策略创建一次 `httpclient.New(cfg, options)` 并并发复用,不能按请求反复建池。配置快照不在运行时修改,每个请求有独立 Body Reader。
|
同一策略创建一次 `httpclient.New(cfg, options)` 并并发复用,不能按请求反复建池。配置快照不在运行时修改,每个请求有独立 Body Reader。
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ require (
|
|||||||
github.com/getkin/kin-openapi v0.153.0
|
github.com/getkin/kin-openapi v0.153.0
|
||||||
github.com/gin-gonic/gin v1.12.0
|
github.com/gin-gonic/gin v1.12.0
|
||||||
github.com/go-playground/validator/v10 v10.30.6
|
github.com/go-playground/validator/v10 v10.30.6
|
||||||
|
github.com/go-redis/redis_rate/v10 v10.0.1
|
||||||
github.com/go-sql-driver/mysql v1.11.0
|
github.com/go-sql-driver/mysql v1.11.0
|
||||||
github.com/goccy/go-yaml v1.19.2
|
github.com/goccy/go-yaml v1.19.2
|
||||||
github.com/google/uuid v1.6.0
|
github.com/google/uuid v1.6.0
|
||||||
@@ -13,6 +14,7 @@ require (
|
|||||||
github.com/mcuadros/go-defaults v1.2.0
|
github.com/mcuadros/go-defaults v1.2.0
|
||||||
github.com/redis/go-redis/v9 v9.24.1
|
github.com/redis/go-redis/v9 v9.24.1
|
||||||
go.uber.org/zap v1.28.0
|
go.uber.org/zap v1.28.0
|
||||||
|
golang.org/x/time v0.16.0
|
||||||
gorm.io/driver/mysql v1.6.0
|
gorm.io/driver/mysql v1.6.0
|
||||||
gorm.io/driver/sqlite v1.6.0
|
gorm.io/driver/sqlite v1.6.0
|
||||||
gorm.io/gorm v1.31.2
|
gorm.io/gorm v1.31.2
|
||||||
@@ -28,7 +30,6 @@ require (
|
|||||||
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.16 // indirect
|
||||||
github.com/gin-contrib/sse v1.2.1 // indirect
|
github.com/gin-contrib/sse v1.2.1 // indirect
|
||||||
github.com/go-openapi/jsonpointer v1.0.3 // indirect
|
github.com/go-openapi/jsonpointer v1.0.3 // indirect
|
||||||
github.com/go-openapi/swag/jsonname v0.29.2 // indirect
|
|
||||||
github.com/go-playground/locales v0.14.2 // indirect
|
github.com/go-playground/locales v0.14.2 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.2 // indirect
|
github.com/go-playground/universal-translator v0.18.2 // indirect
|
||||||
github.com/goccy/go-json v0.12.0 // indirect
|
github.com/goccy/go-json v0.12.0 // indirect
|
||||||
@@ -37,14 +38,13 @@ require (
|
|||||||
github.com/jonboulle/clockwork v0.3.0 // indirect
|
github.com/jonboulle/clockwork v0.3.0 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.4.2 // indirect
|
github.com/klauspost/cpuid/v2 v2.4.2 // indirect
|
||||||
|
github.com/kr/pretty v0.3.1 // indirect
|
||||||
github.com/leodido/go-urn v1.5.0 // indirect
|
github.com/leodido/go-urn v1.5.0 // indirect
|
||||||
github.com/lestrrat-go/strftime v1.2.1 // indirect
|
github.com/lestrrat-go/strftime v1.2.1 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.24 // indirect
|
github.com/mattn/go-isatty v0.0.24 // indirect
|
||||||
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
github.com/mattn/go-sqlite3 v1.14.22 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/oasdiff/yaml v0.1.3 // indirect
|
|
||||||
github.com/oasdiff/yaml3 v0.0.16 // indirect
|
|
||||||
github.com/pelletier/go-toml/v2 v2.4.3 // indirect
|
github.com/pelletier/go-toml/v2 v2.4.3 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/quic-go/qpack v0.6.0 // indirect
|
github.com/quic-go/qpack v0.6.0 // indirect
|
||||||
|
|||||||
@@ -4,76 +4,46 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
|||||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||||
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
|
||||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
|
||||||
github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM=
|
github.com/bytedance/gopkg v0.1.4 h1:oZnQwnX82KAIWb7033bEwtxvTqXcYMxDBaQxo5JJHWM=
|
||||||
github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4=
|
github.com/bytedance/gopkg v0.1.4/go.mod h1:v1zWfPm21Fb+OsyXN2VAHdL6TBb2L88anLQgdyje6R4=
|
||||||
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
|
|
||||||
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
|
|
||||||
github.com/bytedance/sonic v1.15.5 h1:gKWTBfYCIQpQHZ7LpwGf9Gj3N88ZN0G/GaB3EQhiGXE=
|
github.com/bytedance/sonic v1.15.5 h1:gKWTBfYCIQpQHZ7LpwGf9Gj3N88ZN0G/GaB3EQhiGXE=
|
||||||
github.com/bytedance/sonic v1.15.5/go.mod h1:nn7CoK5W+LKbl22XGJrXg6SwzaFAcVs89miqzkqDwOU=
|
github.com/bytedance/sonic v1.15.5/go.mod h1:nn7CoK5W+LKbl22XGJrXg6SwzaFAcVs89miqzkqDwOU=
|
||||||
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
|
|
||||||
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
|
||||||
github.com/bytedance/sonic/loader v0.5.3 h1:ziVGAbXQtLoaot/M6YQxntGkekxz6B/DyuJVwnTbMAA=
|
github.com/bytedance/sonic/loader v0.5.3 h1:ziVGAbXQtLoaot/M6YQxntGkekxz6B/DyuJVwnTbMAA=
|
||||||
github.com/bytedance/sonic/loader v0.5.3/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
github.com/bytedance/sonic/loader v0.5.3/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
|
||||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
|
||||||
github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI=
|
github.com/cloudwego/base64x v0.1.7 h1:NppS+Fgzg5ovhn4NkUXaDT3x9jldgH5ToMCqzBSi2zI=
|
||||||
github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg=
|
github.com/cloudwego/base64x v0.1.7/go.mod h1:Cu1PV9zfrSf7ET2tIbWbbEy7jO7HHJ13q4X2SQ8aWYg=
|
||||||
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
||||||
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI=
|
|
||||||
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
|
||||||
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
github.com/gabriel-vasile/mimetype v1.4.16 h1:5izNFuvA37st1dDRAcA7TtmngBmRgiIPDmTtiEvjx1E=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
github.com/gabriel-vasile/mimetype v1.4.16/go.mod h1:3oFFwxX8kTklZwzIl2aQEDZT0lKY8xH92ST88bAwba4=
|
||||||
github.com/getkin/kin-openapi v0.152.0 h1:XRVo77lMRyOGMHf1paMu9lxX3wzuQDZeprssZJnz/x8=
|
|
||||||
github.com/getkin/kin-openapi v0.152.0/go.mod h1:1+BHDzstro+P5CKtPy1X4PfofnFgmRe6uvMy9+r9fKY=
|
|
||||||
github.com/getkin/kin-openapi v0.153.0 h1:Qo4qWW+Pj8o90LUTE6MDyG5TJAtWnfvrcWOBcWg7eBw=
|
github.com/getkin/kin-openapi v0.153.0 h1:Qo4qWW+Pj8o90LUTE6MDyG5TJAtWnfvrcWOBcWg7eBw=
|
||||||
github.com/getkin/kin-openapi v0.153.0/go.mod h1:mEZ6Ip3gyqPDokUsJsttZhv3r46/NeH3tGwrFUMcoSE=
|
github.com/getkin/kin-openapi v0.153.0/go.mod h1:mEZ6Ip3gyqPDokUsJsttZhv3r46/NeH3tGwrFUMcoSE=
|
||||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
|
||||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
|
||||||
github.com/gin-contrib/sse v1.2.1 h1:VAN6YEQlc6DbKmGYzSHZ72JWk5fp4gZaDwie4+bXx7s=
|
github.com/gin-contrib/sse v1.2.1 h1:VAN6YEQlc6DbKmGYzSHZ72JWk5fp4gZaDwie4+bXx7s=
|
||||||
github.com/gin-contrib/sse v1.2.1/go.mod h1:9ivB3pROCxcwnwHvAoYaHLwNQMGmzCjgriA04TuNIAc=
|
github.com/gin-contrib/sse v1.2.1/go.mod h1:9ivB3pROCxcwnwHvAoYaHLwNQMGmzCjgriA04TuNIAc=
|
||||||
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||||
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||||
github.com/go-openapi/jsonpointer v0.22.5 h1:8on/0Yp4uTb9f4XvTrM2+1CPrV05QPZXu+rvu2o9jcA=
|
|
||||||
github.com/go-openapi/jsonpointer v0.22.5/go.mod h1:gyUR3sCvGSWchA2sUBJGluYMbe1zazrYWIkWPjjMUY0=
|
|
||||||
github.com/go-openapi/jsonpointer v1.0.3 h1:iEtrz/inxw+0za5lr10whyxplQdwJruNoQAFA6Sogso=
|
github.com/go-openapi/jsonpointer v1.0.3 h1:iEtrz/inxw+0za5lr10whyxplQdwJruNoQAFA6Sogso=
|
||||||
github.com/go-openapi/jsonpointer v1.0.3/go.mod h1:rf2X/7HDNST8NkSpeV5gTOJeCZXwcIHyVbr5CPiWSDU=
|
github.com/go-openapi/jsonpointer v1.0.3/go.mod h1:rf2X/7HDNST8NkSpeV5gTOJeCZXwcIHyVbr5CPiWSDU=
|
||||||
github.com/go-openapi/swag/jsonname v0.25.5 h1:8p150i44rv/Drip4vWI3kGi9+4W9TdI3US3uUYSFhSo=
|
|
||||||
github.com/go-openapi/swag/jsonname v0.25.5/go.mod h1:jNqqikyiAK56uS7n8sLkdaNY/uq6+D2m2LANat09pKU=
|
|
||||||
github.com/go-openapi/swag/jsonname v0.29.2 h1:u5e4IQxc7Yxw1APbtOmfY+Lv4lVZSV1KQiMb/Uj35jc=
|
|
||||||
github.com/go-openapi/swag/jsonname v0.29.2/go.mod h1:EMHY1EUECld0oRKGSkA6Vmzw138nWoSpavlVBep6msk=
|
|
||||||
github.com/go-openapi/testify/v2 v2.4.0 h1:8nsPrHVCWkQ4p8h1EsRVymA2XABB4OT40gcvAu+voFM=
|
|
||||||
github.com/go-openapi/testify/v2 v2.4.0/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54=
|
|
||||||
github.com/go-openapi/testify/v2 v2.8.1 h1:zk3S6KaDY1iQW91vsOJc25Ql1xm5bhPrZKdnL930bRQ=
|
github.com/go-openapi/testify/v2 v2.8.1 h1:zk3S6KaDY1iQW91vsOJc25Ql1xm5bhPrZKdnL930bRQ=
|
||||||
|
github.com/go-openapi/testify/v2 v2.8.1/go.mod h1:4gUN8jC+RqOE2qjW/vDmfyTvl5BCht4qL7oca0odrak=
|
||||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
|
||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
|
||||||
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
|
github.com/go-playground/locales v0.14.2 h1:d8UmcrM6Nip0hfGZKLGpAvZH37XB4TS0xzK9B56YNCY=
|
||||||
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.2/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
|
||||||
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
|
github.com/go-playground/universal-translator v0.18.2 h1:LCsMLC9RzmbUMNUPVYD15dmcjwYAJhmX8mPZRW4rAVU=
|
||||||
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
|
github.com/go-playground/universal-translator v0.18.2/go.mod h1:67VZIMp5lQpDWlnStOct22q1bkdJGJqHghbOtmkawxk=
|
||||||
github.com/go-playground/validator/v10 v10.30.5 h1:YyCXvVShZbs2Sm3Mb53eNOlhRXctSOzW5QJAouCTZL4=
|
|
||||||
github.com/go-playground/validator/v10 v10.30.5/go.mod h1:wEqiaov48pXX1kjhc3Da8y0M0Dtg/BK7gurFBLgwFrQ=
|
|
||||||
github.com/go-playground/validator/v10 v10.30.6 h1:E+mymlPNRzAMNz1FShrRvLeGWcprF5w305eLLgWieuo=
|
github.com/go-playground/validator/v10 v10.30.6 h1:E+mymlPNRzAMNz1FShrRvLeGWcprF5w305eLLgWieuo=
|
||||||
github.com/go-playground/validator/v10 v10.30.6/go.mod h1:jPLL8SKCXGe/g87QmEyNw3NO28nmGt5GCnZnufm7rj4=
|
github.com/go-playground/validator/v10 v10.30.6/go.mod h1:jPLL8SKCXGe/g87QmEyNw3NO28nmGt5GCnZnufm7rj4=
|
||||||
github.com/go-sql-driver/mysql v1.10.1 h1:arlSnNLq6a5yxGxV7qg9lF4j0C+KwD6NbQyKr9QL6ME=
|
github.com/go-redis/redis_rate/v10 v10.0.1 h1:calPxi7tVlxojKunJwQ72kwfozdy25RjA0bCj1h0MUo=
|
||||||
github.com/go-sql-driver/mysql v1.10.1/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk=
|
github.com/go-redis/redis_rate/v10 v10.0.1/go.mod h1:EMiuO9+cjRkR7UvdvwMO7vbgqJkltQHtwbdIQvaBKIU=
|
||||||
github.com/go-sql-driver/mysql v1.10.2 h1:5TRvGvczDohUMOCRA5aCAXgfSZOo/oNDSFD/2RrChS0=
|
|
||||||
github.com/go-sql-driver/mysql v1.10.2/go.mod h1:M+cqaI7+xxXGG9swrdeUIoPG3Y3KCkF0pZej+SK+nWk=
|
|
||||||
github.com/go-sql-driver/mysql v1.11.0 h1:0dFnuu2mR7g+8Smo/rL18y1WnTLgVrHttzSahf20Gb4=
|
github.com/go-sql-driver/mysql v1.11.0 h1:0dFnuu2mR7g+8Smo/rL18y1WnTLgVrHttzSahf20Gb4=
|
||||||
github.com/go-sql-driver/mysql v1.11.0/go.mod h1:evJsoGjlO/9BFsnfXyjtluDYb3OSGzPNOnUaBl/2Dao=
|
github.com/go-sql-driver/mysql v1.11.0/go.mod h1:evJsoGjlO/9BFsnfXyjtluDYb3OSGzPNOnUaBl/2Dao=
|
||||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
|
||||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
|
||||||
github.com/goccy/go-json v0.12.0 h1:pD+oWouAiz4yruwXIt/iT+lOMeyhr1aTtxzaMP/RgVI=
|
github.com/goccy/go-json v0.12.0 h1:pD+oWouAiz4yruwXIt/iT+lOMeyhr1aTtxzaMP/RgVI=
|
||||||
github.com/goccy/go-json v0.12.0/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY=
|
github.com/goccy/go-json v0.12.0/go.mod h1:3NdmfEkZlB7YI5UFw/qdFKq8XN1aiWR0YyRPWZNQltY=
|
||||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||||
@@ -91,8 +61,8 @@ github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQy
|
|||||||
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
github.com/jonboulle/clockwork v0.3.0/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/klauspost/cpuid/v2 v2.4.0 h1:S6Hrbc7+ywsr0r+RLapfGBHfyefhCTwEh3A0tV913Dw=
|
github.com/klauspost/compress v1.20.3 h1:zWNoFqq/lSuYQRim3dUXlXeA0IqwuZGicdG5ZTfY5j4=
|
||||||
github.com/klauspost/cpuid/v2 v2.4.0/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
|
github.com/klauspost/compress v1.20.3/go.mod h1:LUdAzn7YLVvxLpc7y3V1m40wESHTgc1422pwwBSKYuI=
|
||||||
github.com/klauspost/cpuid/v2 v2.4.2 h1:xRw7IZEsAgVCp6trS/DgWbTAqpixhmywgVgBjYGg1bQ=
|
github.com/klauspost/cpuid/v2 v2.4.2 h1:xRw7IZEsAgVCp6trS/DgWbTAqpixhmywgVgBjYGg1bQ=
|
||||||
github.com/klauspost/cpuid/v2 v2.4.2/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
|
github.com/klauspost/cpuid/v2 v2.4.2/go.mod h1:19jmZ9mjzoF//ddRSUsv0zfBTJWh3QJh9FNxZTMrGxU=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
@@ -109,8 +79,6 @@ github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible h1:Y6sqxHMyB1D2YSzWkL
|
|||||||
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible/go.mod h1:ZQnN8lSECaebrkQytbHj4xNgtg8CR7RYXnPok8e0EHA=
|
||||||
github.com/lestrrat-go/strftime v1.2.1 h1:LltxP/0ho+7sPY1qiwHQcKK/ksVllY9/8DY3EGFrOaI=
|
github.com/lestrrat-go/strftime v1.2.1 h1:LltxP/0ho+7sPY1qiwHQcKK/ksVllY9/8DY3EGFrOaI=
|
||||||
github.com/lestrrat-go/strftime v1.2.1/go.mod h1:kI9g6UMJkvbykHIC2Nf7BbQ0tgYbZIoD2mOS0f0T+tg=
|
github.com/lestrrat-go/strftime v1.2.1/go.mod h1:kI9g6UMJkvbykHIC2Nf7BbQ0tgYbZIoD2mOS0f0T+tg=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
|
||||||
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=
|
||||||
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=
|
||||||
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
|
||||||
@@ -123,35 +91,22 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
|
|||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/oasdiff/yaml v0.1.1 h1:6nHx+pn9gBRM6YpBlFZFQGCCd1nuvqOBtTD3KKTgGxY=
|
|
||||||
github.com/oasdiff/yaml v0.1.1/go.mod h1:EYJNoyktvWMJ0Hmhx+6qTaqMOsalUaRGT8Sj1hNcegU=
|
|
||||||
github.com/oasdiff/yaml v0.1.3 h1:TdwO8e1G1F+bN++LzHj6IWExcuqMjQ1xK8KRYWTffWE=
|
|
||||||
github.com/oasdiff/yaml v0.1.3/go.mod h1:vxzaFi+b+l+FWC/2NZMm+yD4DzyzwPCwaeLj1x1XfMg=
|
|
||||||
github.com/oasdiff/yaml3 v0.0.14 h1:aLJee3hxBK2H5wdXd9iPcIXb93Nty1Ge0pT171eHtkw=
|
|
||||||
github.com/oasdiff/yaml3 v0.0.14/go.mod h1:csto2xfDjYccdUn/yw/bPjj/cYTdp6HtFA0J4TWG+gg=
|
|
||||||
github.com/oasdiff/yaml3 v0.0.16 h1:NlDF/1oIOhmOvrEb9eH6Sbuubp3gZNS4A+MKST5/p0Q=
|
|
||||||
github.com/oasdiff/yaml3 v0.0.16/go.mod h1:csto2xfDjYccdUn/yw/bPjj/cYTdp6HtFA0J4TWG+gg=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
|
github.com/pelletier/go-toml/v2 v2.4.3 h1:GTRvJQutkOSftxIFD5xw9aepkYNuPWmVJpffdDPYVpY=
|
||||||
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
github.com/pelletier/go-toml/v2 v2.4.3/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
|
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/quic-go/go-ossfuzz-seeds v0.1.0 h1:APacT+iIaNF6fd8AGEiN3bT/Jtkd2jz4v4TzM7MFjy0=
|
||||||
|
github.com/quic-go/go-ossfuzz-seeds v0.1.0/go.mod h1:3IOHRbJIc+L6YKMwfDtJAM9Vj9k0YY4muhuyUYk5tbk=
|
||||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||||
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
|
||||||
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
|
||||||
github.com/quic-go/quic-go v0.66.0 h1:NCsBBGZrI2HZC6aKt4I89T5i4Crt39EYNqkh0w2Wgmg=
|
github.com/quic-go/quic-go v0.66.0 h1:NCsBBGZrI2HZC6aKt4I89T5i4Crt39EYNqkh0w2Wgmg=
|
||||||
github.com/quic-go/quic-go v0.66.0/go.mod h1:RAro2j2yN9a9EiPACLHT9IB2NXCvGQmmo/alT0yYI0w=
|
github.com/quic-go/quic-go v0.66.0/go.mod h1:RAro2j2yN9a9EiPACLHT9IB2NXCvGQmmo/alT0yYI0w=
|
||||||
github.com/redis/go-redis/v9 v9.23.0 h1:/TTVdJa8BRNsybwwGGnmiYktHNlUXtbOQxlWpHBPL3s=
|
|
||||||
github.com/redis/go-redis/v9 v9.23.0/go.mod h1:EWP2UUk+XDaI1s5nQB5mablZN6vccXlmBQTyfnF87D0=
|
|
||||||
github.com/redis/go-redis/v9 v9.24.0 h1:X1AnQHWaSfMeggDQm7UFad1YwJmoZxVm5XkaP0kr6nQ=
|
|
||||||
github.com/redis/go-redis/v9 v9.24.0/go.mod h1:ted97kpLnB4S2KJkTkw+7GzRjgkFnU909IIrksu+ut4=
|
|
||||||
github.com/redis/go-redis/v9 v9.24.1 h1:WZ9a1QO2mkLFLYyQ1IPFvS4xBuCuZy9eXtIxppdj/Z0=
|
github.com/redis/go-redis/v9 v9.24.1 h1:WZ9a1QO2mkLFLYyQ1IPFvS4xBuCuZy9eXtIxppdj/Z0=
|
||||||
github.com/redis/go-redis/v9 v9.24.1/go.mod h1:ted97kpLnB4S2KJkTkw+7GzRjgkFnU909IIrksu+ut4=
|
github.com/redis/go-redis/v9 v9.24.1/go.mod h1:ted97kpLnB4S2KJkTkw+7GzRjgkFnU909IIrksu+ut4=
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28=
|
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3 h1:1EYB5IzjZawrrnELUi78f9fPu57HuXjmddZPjrls/28=
|
||||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
|
github.com/santhosh-tekuri/jsonschema/v6 v6.0.3/go.mod h1:JXeL+ps8p7/KNMjDQk3TCwPpBy0wYklyWTfbkIzdIFU=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
@@ -167,14 +122,10 @@ github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWD
|
|||||||
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
|
||||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
|
||||||
github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc=
|
github.com/ugorji/go/codec v1.3.2 h1:zkEASHHyEClGeURfgNT9PJZVfAbs9oEX9QXggwWNJbc=
|
||||||
github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
github.com/ugorji/go/codec v1.3.2/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
github.com/zeebo/xxh3 v1.1.0 h1:s7DLGDK45Dyfg7++yxI0khrfwq9661w9EN78eP/UZVs=
|
||||||
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
github.com/zeebo/xxh3 v1.1.0/go.mod h1:IisAie1LELR4xhVinxWS5+zf1lA4p0MW4T+w+W07F5s=
|
||||||
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
|
|
||||||
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
|
||||||
go.mongodb.org/mongo-driver/v2 v2.10.1 h1:FScYVU+0h/zERnvYemJix3ZDgeU2QGmC8EuXLSWLdf8=
|
go.mongodb.org/mongo-driver/v2 v2.10.1 h1:FScYVU+0h/zERnvYemJix3ZDgeU2QGmC8EuXLSWLdf8=
|
||||||
go.mongodb.org/mongo-driver/v2 v2.10.1/go.mod h1:PxPyIAlsI1jkYZvUNfTr++ggyBP+RSaxHYctt6TcZc4=
|
go.mongodb.org/mongo-driver/v2 v2.10.1/go.mod h1:PxPyIAlsI1jkYZvUNfTr++ggyBP+RSaxHYctt6TcZc4=
|
||||||
go.uber.org/atomic v1.12.0 h1:BvcXdFKuviU4fTL/f+SxdQ5qJX/Jix8pAkgdUcb3XOE=
|
go.uber.org/atomic v1.12.0 h1:BvcXdFKuviU4fTL/f+SxdQ5qJX/Jix8pAkgdUcb3XOE=
|
||||||
@@ -183,8 +134,6 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
|||||||
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
|
||||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||||
go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ=
|
|
||||||
go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
|
||||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||||
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
|
go.uber.org/zap v1.28.0 h1:IZzaP1Fv73/T/pBMLk4VutPl36uNC+OSUh3JLG3FIjo=
|
||||||
@@ -193,29 +142,18 @@ go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
|||||||
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
go.yaml.in/yaml/v4 v4.0.0 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw=
|
go.yaml.in/yaml/v4 v4.0.0 h1:/LG1pNO84Z4l603j/xMn69CcS5OYhMQ/f7l2LoQUGuw=
|
||||||
go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
go.yaml.in/yaml/v4 v4.0.0/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||||
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
|
||||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
|
||||||
golang.org/x/arch v0.33.0 h1:Xhs4e8nHj/CU/eFFMok2wQG3amA8430Sjdobboa4NrM=
|
golang.org/x/arch v0.33.0 h1:Xhs4e8nHj/CU/eFFMok2wQG3amA8430Sjdobboa4NrM=
|
||||||
golang.org/x/arch v0.33.0/go.mod h1:yelN722/RE0EdL5KBgAqvVqP++p/dn8sL4UaLD8n8As=
|
golang.org/x/arch v0.33.0/go.mod h1:yelN722/RE0EdL5KBgAqvVqP++p/dn8sL4UaLD8n8As=
|
||||||
golang.org/x/crypto v0.58.0 h1:COkYLr4k7nDI4r6QtMML2AfzeIswWHAJthLS6K/M/54=
|
|
||||||
golang.org/x/crypto v0.58.0/go.mod h1:Xh+kl5A+M0gMiWDytH2Hhr5Z7WbNCpv/eB/EFgfSk+w=
|
|
||||||
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
|
golang.org/x/crypto v0.59.0 h1:xS2jhqYbzNrpvkWP2YTDf4TJwBy3ykR03i8vFDxEc7c=
|
||||||
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
|
golang.org/x/crypto v0.59.0/go.mod h1:veDyUwATGs3c+vN3VfTbzViMGXeTBk3WyhBOkn+F/4U=
|
||||||
golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY=
|
|
||||||
golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI=
|
|
||||||
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0=
|
||||||
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
|
golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
|
||||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
|
||||||
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs=
|
||||||
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc=
|
|
||||||
golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s=
|
|
||||||
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
|
||||||
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
|
||||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE=
|
||||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s=
|
||||||
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc=
|
||||||
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -0,0 +1,204 @@
|
|||||||
|
// Package cors 提供独立于业务身份的来源匹配、预检和跨域响应头。
|
||||||
|
package cors
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
failure "git.zhangdeman.cn/zhangdeman/ginframework/internal/failure"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
codeOrigins = 900801
|
||||||
|
codeCredentials = 900802
|
||||||
|
codeOriginPattern = 900803
|
||||||
|
codeMaxAge = 900804
|
||||||
|
)
|
||||||
|
|
||||||
|
// Config 只保存跨域策略数据;零 MaxAge 不缓存预检,名单不会隐式扩展。
|
||||||
|
type Config struct {
|
||||||
|
AllowAllOrigins bool `json:"allow_all_origins" yaml:"allow_all_origins" dc:"允许任意来源,与凭据模式互斥"`
|
||||||
|
AllowOrigins []string `json:"allow_origins" yaml:"allow_origins" dc:"明确的 HTTP/HTTPS 来源名单"`
|
||||||
|
AllowMethods []string `json:"allow_methods" yaml:"allow_methods" dc:"预检允许的方法,星号允许任意方法"`
|
||||||
|
AllowHeaders []string `json:"allow_headers" yaml:"allow_headers" dc:"预检允许的请求头,星号允许任意请求头"`
|
||||||
|
ExposeHeaders []string `json:"expose_headers" yaml:"expose_headers" dc:"允许浏览器读取的响应头"`
|
||||||
|
AllowCredentials bool `json:"allow_credentials" yaml:"allow_credentials" dc:"允许请求携带凭据,必须回显明确来源"`
|
||||||
|
AllowWildcard bool `json:"allow_wildcard" yaml:"allow_wildcard" dc:"允许名单中出现单个星号来源规则"`
|
||||||
|
CheckActualMethod bool `json:"check_actual_method" yaml:"check_actual_method" dc:"除预检外也拒绝名单之外的实际跨域方法"`
|
||||||
|
MaxAge time.Duration `json:"max_age" yaml:"max_age" dc:"预检缓存时长,零不缓存,拒绝负值"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Options 显式提供应用自己的动态来源授权和拒绝响应,不进入配置解码。
|
||||||
|
type Options struct {
|
||||||
|
AllowOrigin func(*gin.Context, string) bool `json:"-" dc:"静态名单未匹配时的可信来源授权,可处理扩展等来源"`
|
||||||
|
OnOriginDenied gin.HandlerFunc `json:"-" dc:"来源拒绝时的可选业务响应,缺省为 403;框架始终终止处理"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// DefaultConfig 返回标准方法和基础请求头、十二小时缓存;调用方仍须声明来源。
|
||||||
|
func DefaultConfig() Config {
|
||||||
|
return Config{AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"}, AllowHeaders: []string{"Origin", "Content-Length", "Content-Type"}, MaxAge: 12 * time.Hour}
|
||||||
|
}
|
||||||
|
|
||||||
|
// New 校验一次策略并复制名单,返回可注册到 Gin/框架 Use 的处理器。
|
||||||
|
// 入参:cfg 为数据,options 为应用运行函数;静态来源只接受 HTTP/HTTPS origin 和显式单星号规则。
|
||||||
|
// 返回:构造失败保留内部原因链,不使用 panic;无 Origin 或同源请求直接通过,预检成功返回 204。
|
||||||
|
// 隐式逻辑:凭据模式禁止星号 Origin,方法和头的星号按请求回显;已有 Vary 会合并保留。
|
||||||
|
func New(cfg Config, options Options) (gin.HandlerFunc, error) {
|
||||||
|
cfg.AllowOrigins = normalize(cfg.AllowOrigins)
|
||||||
|
cfg.AllowMethods = normalize(cfg.AllowMethods)
|
||||||
|
cfg.AllowHeaders = normalize(cfg.AllowHeaders)
|
||||||
|
cfg.ExposeHeaders = normalize(cfg.ExposeHeaders)
|
||||||
|
if cfg.MaxAge < 0 {
|
||||||
|
return nil, failure.Wrap(codeMaxAge, "validate CORS preflight lifetime failed", errors.New("negative preflight lifetime"))
|
||||||
|
}
|
||||||
|
if contains(cfg.AllowOrigins, "*") {
|
||||||
|
cfg.AllowAllOrigins = true
|
||||||
|
}
|
||||||
|
if cfg.AllowAllOrigins && cfg.AllowCredentials {
|
||||||
|
return nil, failure.Wrap(codeCredentials, "validate CORS credential policy failed", errors.New("credentials require explicit origins"))
|
||||||
|
}
|
||||||
|
if cfg.AllowAllOrigins && (options.AllowOrigin != nil || len(cfg.AllowOrigins) > 1 || len(cfg.AllowOrigins) == 1 && cfg.AllowOrigins[0] != "*") {
|
||||||
|
return nil, failure.Wrap(codeOrigins, "validate CORS origin policy failed", errors.New("wildcard origin conflicts with explicit origin rules"))
|
||||||
|
}
|
||||||
|
if !cfg.AllowAllOrigins && len(cfg.AllowOrigins) == 0 && options.AllowOrigin == nil {
|
||||||
|
return nil, failure.Wrap(codeOrigins, "validate CORS origin policy failed", errors.New("origin rule is required"))
|
||||||
|
}
|
||||||
|
for _, origin := range cfg.AllowOrigins {
|
||||||
|
if origin == "*" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if !webOrigin(origin) || strings.Count(origin, "*") > 1 || strings.Contains(origin, "*") && !cfg.AllowWildcard {
|
||||||
|
return nil, failure.Wrap(codeOriginPattern, "validate CORS origin pattern failed", errors.New("invalid origin scheme, shape or wildcard declaration"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return func(ctx *gin.Context) {
|
||||||
|
origin := strings.TrimSpace(ctx.GetHeader("Origin"))
|
||||||
|
if origin == "" || origin == "http://"+ctx.Request.Host || origin == "https://"+ctx.Request.Host {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
allowed := cfg.AllowAllOrigins
|
||||||
|
for _, rule := range cfg.AllowOrigins {
|
||||||
|
if strings.EqualFold(rule, origin) {
|
||||||
|
allowed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if cfg.AllowWildcard && strings.Contains(rule, "*") && webOrigin(origin) {
|
||||||
|
before, after, _ := strings.Cut(rule, "*")
|
||||||
|
candidate := strings.ToLower(origin)
|
||||||
|
if strings.HasPrefix(candidate, before) && strings.HasSuffix(candidate, after) && len(candidate) >= len(before)+len(after) {
|
||||||
|
allowed = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !allowed && options.AllowOrigin != nil {
|
||||||
|
allowed = options.AllowOrigin(ctx, origin)
|
||||||
|
}
|
||||||
|
if !allowed {
|
||||||
|
if options.OnOriginDenied != nil {
|
||||||
|
options.OnOriginDenied(ctx)
|
||||||
|
ctx.Abort()
|
||||||
|
} else {
|
||||||
|
ctx.AbortWithStatus(http.StatusForbidden)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if cfg.CheckActualMethod && ctx.Request.Method != http.MethodOptions && !contains(cfg.AllowMethods, ctx.Request.Method) && !contains(cfg.AllowMethods, "*") {
|
||||||
|
ctx.AbortWithStatus(http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
header := ctx.Writer.Header()
|
||||||
|
if cfg.AllowAllOrigins {
|
||||||
|
header.Set("Access-Control-Allow-Origin", "*")
|
||||||
|
} else {
|
||||||
|
header.Set("Access-Control-Allow-Origin", origin)
|
||||||
|
appendVary(header, "Origin")
|
||||||
|
}
|
||||||
|
if cfg.AllowCredentials {
|
||||||
|
header.Set("Access-Control-Allow-Credentials", "true")
|
||||||
|
}
|
||||||
|
if ctx.Request.Method != http.MethodOptions {
|
||||||
|
if len(cfg.ExposeHeaders) > 0 {
|
||||||
|
header.Set("Access-Control-Expose-Headers", strings.Join(cfg.ExposeHeaders, ","))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
method := strings.ToUpper(strings.TrimSpace(ctx.GetHeader("Access-Control-Request-Method")))
|
||||||
|
if !contains(cfg.AllowMethods, "*") && !contains(cfg.AllowMethods, method) {
|
||||||
|
ctx.AbortWithStatus(http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
requested := strings.TrimSpace(ctx.GetHeader("Access-Control-Request-Headers"))
|
||||||
|
if !contains(cfg.AllowHeaders, "*") {
|
||||||
|
for _, name := range strings.Split(requested, ",") {
|
||||||
|
if strings.TrimSpace(name) != "" && !contains(cfg.AllowHeaders, name) {
|
||||||
|
ctx.AbortWithStatus(http.StatusForbidden)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
methods := strings.ToUpper(strings.Join(cfg.AllowMethods, ", "))
|
||||||
|
if contains(cfg.AllowMethods, "*") && cfg.AllowCredentials {
|
||||||
|
methods = method
|
||||||
|
}
|
||||||
|
header.Set("Access-Control-Allow-Methods", methods)
|
||||||
|
if requested != "" {
|
||||||
|
if cfg.AllowCredentials || contains(cfg.AllowHeaders, "*") {
|
||||||
|
header.Set("Access-Control-Allow-Headers", requested)
|
||||||
|
} else {
|
||||||
|
header.Set("Access-Control-Allow-Headers", strings.Join(cfg.AllowHeaders, ","))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if cfg.MaxAge > 0 {
|
||||||
|
header.Set("Access-Control-Max-Age", strconv.FormatInt(int64(cfg.MaxAge/time.Second), 10))
|
||||||
|
}
|
||||||
|
appendVary(header, "Access-Control-Request-Method")
|
||||||
|
appendVary(header, "Access-Control-Request-Headers")
|
||||||
|
ctx.AbortWithStatus(http.StatusNoContent)
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// normalize 复制并规范化构造期名单,避免请求读取调用方的可变切片。
|
||||||
|
func normalize(values []string) []string {
|
||||||
|
result := make([]string, 0, len(values))
|
||||||
|
for _, value := range values {
|
||||||
|
value = strings.ToLower(strings.TrimSpace(value))
|
||||||
|
if value != "" && !contains(result, value) {
|
||||||
|
result = append(result, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
// contains 对方法、来源和请求头执行大小写不敏感的完整项匹配。
|
||||||
|
func contains(values []string, value string) bool {
|
||||||
|
for _, entry := range values {
|
||||||
|
if strings.EqualFold(entry, strings.TrimSpace(value)) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// appendVary 保留既有协商条件,合并同名项时不重复输出。
|
||||||
|
func appendVary(header http.Header, value string) {
|
||||||
|
for _, existing := range header.Values("Vary") {
|
||||||
|
for _, item := range strings.Split(existing, ",") {
|
||||||
|
if strings.EqualFold(strings.TrimSpace(item), value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
header.Add("Vary", value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// webOrigin 检查来源 URL 的 origin 形状,拒绝凭据、路径、查询和片段参与通配匹配。
|
||||||
|
func webOrigin(origin string) bool {
|
||||||
|
parsed, err := url.Parse(origin)
|
||||||
|
return err == nil && (parsed.Scheme == "http" || parsed.Scheme == "https") && parsed.Host != "" && parsed.User == nil && parsed.Path == "" && parsed.RawQuery == "" && parsed.Fragment == "" && parsed.Opaque == ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package cors
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestCredentialedPreflightAndVary 验证真实预检凭据协议、方法/头白名单和已有 Vary 合并。
|
||||||
|
func TestCredentialedPreflightAndVary(t *testing.T) {
|
||||||
|
for _, item := range []struct {
|
||||||
|
name, origin, method, headers string
|
||||||
|
want int
|
||||||
|
}{
|
||||||
|
{"allowed", "https://app.example.test", "POST", "Authorization,Last-Event-ID", 204},
|
||||||
|
{"origin denied", "https://other.example.test", "POST", "Authorization", 403},
|
||||||
|
{"method denied", "https://app.example.test", "DELETE", "Authorization", 403},
|
||||||
|
{"header denied", "https://app.example.test", "POST", "X-Unknown", 403},
|
||||||
|
} {
|
||||||
|
t.Run(item.name, func(t *testing.T) {
|
||||||
|
middleware, err := New(Config{AllowOrigins: []string{"https://app.example.test"}, AllowMethods: []string{"GET", "POST"}, AllowHeaders: []string{"Authorization", "Last-Event-ID"}, AllowCredentials: true}, Options{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
engine := gin.New()
|
||||||
|
engine.Use(func(ctx *gin.Context) { ctx.Header("Vary", "Accept-Encoding"); ctx.Next() }, middleware)
|
||||||
|
engine.OPTIONS("/api", func(*gin.Context) { t.Error("preflight reached application handler") })
|
||||||
|
request := httptest.NewRequest(http.MethodOptions, "/api", nil)
|
||||||
|
request.Header.Set("Origin", item.origin)
|
||||||
|
request.Header.Set("Access-Control-Request-Method", item.method)
|
||||||
|
request.Header.Set("Access-Control-Request-Headers", item.headers)
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
engine.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != item.want {
|
||||||
|
t.Fatalf("status=%d, want %d", recorder.Code, item.want)
|
||||||
|
}
|
||||||
|
if item.want == 204 {
|
||||||
|
if recorder.Header().Get("Access-Control-Allow-Origin") != item.origin || recorder.Header().Get("Access-Control-Allow-Credentials") != "true" || recorder.Header().Get("Access-Control-Allow-Headers") != item.headers {
|
||||||
|
t.Fatal("credential preflight headers changed")
|
||||||
|
}
|
||||||
|
vary := strings.Join(recorder.Header().Values("Vary"), ",")
|
||||||
|
for _, token := range []string{"Accept-Encoding", "Origin", "Access-Control-Request-Method", "Access-Control-Request-Headers"} {
|
||||||
|
if !strings.Contains(vary, token) {
|
||||||
|
t.Fatalf("lost Vary %s", token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCORSRejectsInvalidConfig 凭据和全来源互斥,静态来源不接受文件协议或未声明通配符。
|
||||||
|
func TestCORSRejectsInvalidConfig(t *testing.T) {
|
||||||
|
for _, cfg := range []Config{{}, {AllowAllOrigins: true, AllowCredentials: true}, {AllowOrigins: []string{"*"}, AllowCredentials: true}, {AllowOrigins: []string{"file://local"}}, {AllowOrigins: []string{"https://*.example.test"}}, {AllowOrigins: []string{"https://app.example.test/path"}}} {
|
||||||
|
if _, err := New(cfg, Options{}); err == nil {
|
||||||
|
t.Fatalf("invalid policy accepted: %#v", cfg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCORSRuntimePolicyAndFrozenConfig 验证应用回调处理扩展拒绝响应,配置切片不会被调用方后续修改。
|
||||||
|
func TestCORSRuntimePolicyAndFrozenConfig(t *testing.T) {
|
||||||
|
cfg := Config{AllowOrigins: []string{"https://app.example.test"}, AllowMethods: []string{"GET"}}
|
||||||
|
middleware, err := New(cfg, Options{AllowOrigin: func(_ *gin.Context, origin string) bool { return origin == "chrome-extension://registered" }, OnOriginDenied: func(ctx *gin.Context) { ctx.JSON(http.StatusUnauthorized, gin.H{"denied": true}) }})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
cfg.AllowOrigins[0] = "https://attacker.example.test"
|
||||||
|
engine := gin.New()
|
||||||
|
engine.Use(middleware)
|
||||||
|
engine.GET("/api", func(ctx *gin.Context) { ctx.Status(http.StatusNoContent) })
|
||||||
|
for _, item := range []struct {
|
||||||
|
origin string
|
||||||
|
want int
|
||||||
|
}{{"https://app.example.test", 204}, {"https://attacker.example.test", 401}, {"chrome-extension://registered", 204}} {
|
||||||
|
request := httptest.NewRequest(http.MethodGet, "/api", nil)
|
||||||
|
request.Header.Set("Origin", item.origin)
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
engine.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != item.want {
|
||||||
|
t.Fatalf("origin %s status=%d", item.origin, recorder.Code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCredentialWildcardEchoesPreflight 验证显式动态来源授权下的方法和请求头通配符回显。
|
||||||
|
func TestCredentialWildcardEchoesPreflight(t *testing.T) {
|
||||||
|
middleware, err := New(Config{AllowMethods: []string{"*"}, AllowHeaders: []string{"*"}, AllowCredentials: true}, Options{AllowOrigin: func(*gin.Context, string) bool { return true }})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
engine := gin.New()
|
||||||
|
engine.Use(middleware)
|
||||||
|
request := httptest.NewRequest(http.MethodOptions, "/api", nil)
|
||||||
|
request.Header.Set("Origin", "https://client.example.test")
|
||||||
|
request.Header.Set("Access-Control-Request-Method", "PATCH")
|
||||||
|
request.Header.Set("Access-Control-Request-Headers", "Authorization,X-Custom")
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
engine.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != 204 || recorder.Header().Get("Access-Control-Allow-Methods") != "PATCH" || recorder.Header().Get("Access-Control-Allow-Headers") != "Authorization,X-Custom" {
|
||||||
|
t.Fatal("credential wildcard was not echoed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestCORSWildcardMatchesOriginsOnly 防止 URL 路径被当作主机通配来源匹配。
|
||||||
|
func TestCORSWildcardMatchesOriginsOnly(t *testing.T) {
|
||||||
|
handler, err := New(Config{AllowOrigins: []string{"https://*.example.test"}, AllowWildcard: true, AllowMethods: []string{"GET"}}, Options{})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
engine := gin.New()
|
||||||
|
engine.Use(handler)
|
||||||
|
engine.GET("/", func(ctx *gin.Context) { ctx.Status(http.StatusNoContent) })
|
||||||
|
for _, item := range []struct {
|
||||||
|
origin string
|
||||||
|
want int
|
||||||
|
}{{"https://client.example.test", 204}, {"https://evil.test/path.example.test", 403}, {"https://client.example.test?x=.example.test", 403}} {
|
||||||
|
request := httptest.NewRequest(http.MethodGet, "/", nil)
|
||||||
|
request.Header.Set("Origin", item.origin)
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
engine.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != item.want {
|
||||||
|
t.Fatalf("origin %s status=%d", item.origin, recorder.Code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// Package scalar 提供可选的内嵌 Scalar 页面,不负责生成或发布 OpenAPI 契约。
|
||||||
|
package scalar
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
"html"
|
||||||
|
"mime"
|
||||||
|
"net/http"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// 文档界面固定为 Scalar,页面和脚本随二进制发布,不从 CDN 加载运行代码。
|
||||||
|
var (
|
||||||
|
//go:embed theme/scalar
|
||||||
|
scalarFiles embed.FS
|
||||||
|
)
|
||||||
|
|
||||||
|
// UI 保存固定文档界面的渲染参数,不提供主题选择能力。
|
||||||
|
type UI struct {
|
||||||
|
baseURI string `dc:"文档页面的基础路由"`
|
||||||
|
title string `dc:"文档页面标题"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// New 创建使用内置资源的 Scalar 文档界面。
|
||||||
|
// 入参:title 为页面标题;baseURI 为已经注册的文档基础路径。
|
||||||
|
// 返回:绑定文档路径与标题的界面实例。
|
||||||
|
func New(title, baseURI string) *UI {
|
||||||
|
return &UI{
|
||||||
|
baseURI: strings.TrimRight(baseURI, "/"),
|
||||||
|
title: title,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handler 提供固定 Scalar 页面与脚本,未知资源返回 404。
|
||||||
|
// 返回:读取内嵌资源并注入安全页面参数的 Gin 处理器。
|
||||||
|
func (ui *UI) Handler() gin.HandlerFunc {
|
||||||
|
return func(ctx *gin.Context) {
|
||||||
|
var (
|
||||||
|
requested = strings.TrimPrefix(ctx.Param("any"), "/")
|
||||||
|
data []byte
|
||||||
|
err error
|
||||||
|
contentType string
|
||||||
|
page string
|
||||||
|
)
|
||||||
|
if requested == "" {
|
||||||
|
requested = "index.html"
|
||||||
|
}
|
||||||
|
// 仅公开当前文档使用的两个资源,拒绝其他主题和路径穿越请求。
|
||||||
|
if requested != "index.html" && requested != "api-reference.js" {
|
||||||
|
ctx.AbortWithStatus(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if data, err = scalarFiles.ReadFile(path.Join("theme/scalar", requested)); err != nil {
|
||||||
|
// 资源固定且编译时嵌入,不存在的路径按静态资源协议返回 404。
|
||||||
|
ctx.AbortWithStatus(http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
contentType = mime.TypeByExtension(path.Ext(requested))
|
||||||
|
if requested == "index.html" {
|
||||||
|
page = strings.ReplaceAll(string(data), "{{DOC_TITLE}}", html.EscapeString(ui.title))
|
||||||
|
page = strings.ReplaceAll(page, "{{BASE_URI}}", html.EscapeString(ui.baseURI))
|
||||||
|
data = []byte(page)
|
||||||
|
contentType = "text/html; charset=utf-8"
|
||||||
|
}
|
||||||
|
ctx.Data(http.StatusOK, contentType, data)
|
||||||
|
ctx.Abort()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package scalar
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestScalarUIHandlesQueryAndMissingAssets(t *testing.T) {
|
||||||
|
engine := gin.New()
|
||||||
|
engine.GET("/docs/*any", New("Test <API>", "/docs").Handler())
|
||||||
|
|
||||||
|
t.Run("index with query", func(t *testing.T) {
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
request := httptest.NewRequest(http.MethodGet, "/docs/index.html?cache=1", nil)
|
||||||
|
engine.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusOK {
|
||||||
|
t.Fatalf("status = %d, want %d", recorder.Code, http.StatusOK)
|
||||||
|
}
|
||||||
|
if contentType := recorder.Header().Get("Content-Type"); !strings.HasPrefix(contentType, "text/html") {
|
||||||
|
t.Fatalf("Content-Type = %q, want HTML", contentType)
|
||||||
|
}
|
||||||
|
if strings.Contains(recorder.Body.String(), "Test <API>") {
|
||||||
|
t.Fatal("document title was not HTML escaped")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
t.Run("missing asset", func(t *testing.T) {
|
||||||
|
recorder := httptest.NewRecorder()
|
||||||
|
request := httptest.NewRequest(http.MethodGet, "/docs/missing.js", nil)
|
||||||
|
engine.ServeHTTP(recorder, request)
|
||||||
|
if recorder.Code != http.StatusNotFound {
|
||||||
|
t.Fatalf("status = %d, want %d", recorder.Code, http.StatusNotFound)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/**
|
||||||
|
* Minified by jsDelivr using Terser v5.39.0.
|
||||||
|
* Original file: /npm/@scalar/api-reference@1.43.0/dist/browser/standalone.js
|
||||||
|
*
|
||||||
|
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
||||||
|
*/
|
||||||
|
!function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.references-classic-header[data-v-9198d025]{display:flex;align-items:center;gap:12px;max-width:var(--refs-content-max-width);margin:auto;padding:12px 0}.references-classic-header-content[data-v-9198d025]{display:flex;gap:12px;flex-grow:1}.references-classic-header-container[data-v-9198d025]{padding:0 60px}@container narrow-references-container (max-width: 900px){.references-classic-header[data-v-9198d025]{padding:12px 24px}.references-classic-header-container[data-v-9198d025]{padding:0}}.references-classic-header-icon[data-v-9198d025]{height:24px;color:var(--scalar-color-1)}.client-libraries-content[data-v-6a49c111]{container:client-libraries-content / inline-size;display:flex;justify-content:center;overflow:hidden;padding:0 12px;background-color:var(--scalar-background-1);border-left:var(--scalar-border-width) solid var(--scalar-border-color);border-right:var(--scalar-border-width) solid var(--scalar-border-color)}.client-libraries[data-v-6a49c111]{display:flex;align-items:center;justify-content:center;width:100%;position:relative;cursor:pointer;white-space:nowrap;padding:8px 2px;gap:6px;color:var(--scalar-color-3);border-bottom:1px solid transparent;-webkit-user-select:none;user-select:none}.client-libraries[data-v-6a49c111]:not(.client-libraries__active):hover:before{content:"";position:absolute;width:calc(100% - 4px);height:calc(100% - 4px);background:var(--scalar-background-2);left:2px;top:2px;z-index:0;border-radius:var(--scalar-radius)}.client-libraries[data-v-6a49c111]:active{color:var(--scalar-color-1)}.client-libraries[data-v-6a49c111]:focus-visible{outline:none;box-shadow:inset 0 0 0 1px var(--scalar-color-accent)}@media screen and (max-width: 450px){.client-libraries[data-v-6a49c111]:nth-of-type(4),.client-libraries[data-v-6a49c111]:nth-of-type(5){display:none}}.client-libraries-icon[data-v-6a49c111]{max-width:14px;max-height:14px;min-width:14px;width:100%;aspect-ratio:1;display:flex;align-items:center;justify-content:center;position:relative;box-sizing:border-box;color:currentColor}.client-libraries-icon__more svg[data-v-6a49c111]{height:initial}@container client-libraries-content (width < 400px){.client-libraries__select[data-v-6a49c111]{width:fit-content}.client-libraries__select .client-libraries-icon__more+span[data-v-6a49c111]{display:none}}@container client-libraries-content (width < 380px){.client-libraries[data-v-6a49c111]{width:100%}.client-libraries span[data-v-6a49c111]{display:none}}.client-libraries__active[data-v-6a49c111]{color:var(--scalar-color-1);border-bottom:1px solid var(--scalar-color-1)}@keyframes codeloader-6a49c111{0%{transform:rotate(0)}to{transform:rotate(1turn)}}.client-libraries .client-libraries-text[data-v-6a49c111]{font-size:var(--scalar-small);position:relative;display:flex;align-items:center}.client-libraries__active .client-libraries-text[data-v-6a49c111]{color:var(--scalar-color-1);font-weight:var(--scalar-semibold)}@media screen and (max-width: 600px){.references-classic .client-libraries[data-v-6a49c111]{flex-direction:column}}.selected-client[data-v-e59e2ca0]{color:var(--scalar-color-1);font-size:var(--scalar-small);font-family:var(--scalar-font-code);padding:9px 12px;border-top:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:var(--scalar-background-1);border:var(--scalar-border-width) solid var(--scalar-border-color);border-bottom-left-radius:var(--scalar-radius-lg);border-bottom-right-radius:var(--scalar-radius-lg);min-height:fit-content}.client-libraries-heading[data-v-e59e2ca0]{font-size:var(--scalar-small);font-weight:var(--scalar-font-medium);color:var(--scalar-color-1);padding:9px 12px;background-color:var(--scalar-background-2);display:flex;align-items:center;max-height:32px;border:var(--scalar-border-width) solid var(--scalar-border-color);border-top-left-radius:var(--scalar-radius-lg);border-top-right-radius:var(--scalar-radius-lg)}[data-v-e59e2ca0] .scalar-codeblock-pre .hljs{margin-top:8px}.badge[data-v-3dedb7e4]{color:var(--badge-text-color, var(--scalar-color-2));font-size:var(--scalar-mini);background:var(--badge-background-color, var(--scalar-background-2));border:var(--scalar-border-width) solid var(--badge-border-color, var(--scalar-border-color));padding:2px 6px;border-radius:12px;display:inline-block}.badge.text-orange[data-v-3dedb7e4]{background:color-mix(in srgb,var(--scalar-color-orange),transparent 90%);border:transparent}.badge.text-yellow[data-v-3dedb7e4]{background:color-mix(in srgb,var(--scalar-color-yellow),transparent 90%);border:transparent}.badge.text-red[data-v-3dedb7e4]{background:color-mix(in srgb,var(--scalar-color-red),transparent 90%);border:transparent}.badge.text-purple[data-v-3dedb7e4]{background:color-mix(in srgb,var(--scalar-color-purple),transparent 90%);border:transparent}.badge.text-green[data-v-3dedb7e4]{background:color-mix(in srgb,var(--scalar-cLine truncated
|
||||||
|
/**
|
||||||
|
* @vue/shared v3.5.21
|
||||||
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||||
|
* @license MIT
|
||||||
|
**/function gu(e){const t=Object.create(null);for(const n of e.split(","))t[n]=1;return e=>e in t}const vu={},bu=[],yu=()=>{},Ou=()=>!1,wu=e=>111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&(e.charCodeAt(2)>122||e.charCodeAt(2)<97),xu=e=>e.startsWith("onUpdate:"),ku=Object.assign,Su=(e,t)=>{const n=e.indexOf(t);n>-1&&e.splice(n,1)},_u=Object.prototype.hasOwnProperty,Tu=(e,t)=>_u.call(e,t),Eu=Array.isArray,Au=e=>"[object Map]"===Lu(e),Cu=e=>"[object Set]"===Lu(e),Pu=e=>"[object Date]"===Lu(e),$u=e=>"function"==typeof e,Du=e=>"string"==typeof e,Iu=e=>"symbol"==typeof e,Mu=e=>null!==e&&"object"==typeof e,Nu=e=>(Mu(e)||$u(e))&&$u(e.then)&&$u(e.catch),Ru=Object.prototype.toString,Lu=e=>Ru.call(e),Bu=e=>"[object Object]"===Lu(e),ju=e=>Du(e)&&"NaN"!==e&&"-"!==e[0]&&""+parseInt(e,10)===e,Uu=gu(",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"),zu=e=>{const t=Object.create(null);return n=>t[n]||(t[n]=e(n))},Fu=/-\w/g,Qu=zu((e=>e.replace(Fu,(e=>e.slice(1).toUpperCase())))),Zu=/\B([A-Z])/g,Hu=zu((e=>e.replace(Zu,"-$1").toLowerCase())),Vu=zu((e=>e.charAt(0).toUpperCase()+e.slice(1))),qu=zu((e=>e?`on${Vu(e)}`:"")),Wu=(e,t)=>!Object.is(e,t),Xu=(e,...t)=>{for(let n=0;n<e.length;n++)e[n](...t)},Gu=(e,t,n,r=!1)=>{Object.defineProperty(e,t,{configurable:!0,enumerable:!1,writable:r,value:n})},Yu=e=>{const t=parseFloat(e);return isNaN(t)?e:t};let Ku;const Ju=()=>Ku||(Ku="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{});function ed(e){if(Eu(e)){const t={};for(let n=0;n<e.length;n++){const r=e[n],a=Du(r)?ad(r):ed(r);if(a)for(const e in a)t[e]=a[e]}return t}if(Du(e)||Mu(e))return e}const td=/;(?![^(]*\))/g,nd=/:([^]+)/,rd=/\/\*[^]*?\*\//g;function ad(e){const t={};return e.replace(rd,"").split(td).forEach((e=>{if(e){const n=e.split(nd);n.length>1&&(t[n[0].trim()]=n[1].trim())}})),t}function od(e){let t="";if(Du(e))t=e;else if(Eu(e))for(let n=0;n<e.length;n++){const r=od(e[n]);r&&(t+=r+" ")}else if(Mu(e))for(const n in e)e[n]&&(t+=n+" ");return t.trim()}function id(e){if(!e)return null;let{class:t,style:n}=e;return t&&!Du(t)&&(e.class=od(t)),n&&(e.style=ed(n)),e}const sd=gu("itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly");function ld(e){return!!e||""===e}function cd(e,t){if(e===t)return!0;let n=Pu(e),r=Pu(t);if(n||r)return!(!n||!r)&&e.getTime()===t.getTime();if(n=Iu(e),r=Iu(t),n||r)return e===t;if(n=Eu(e),r=Eu(t),n||r)return!(!n||!r)&&function(e,t){if(e.length!==t.length)return!1;let n=!0;for(let r=0;n&&r<e.length;r++)n=cd(e[r],t[r]);return n}(e,t);if(n=Mu(e),r=Mu(t),n||r){if(!n||!r)return!1;if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e){const r=e.hasOwnProperty(n),a=t.hasOwnProperty(n);if(r&&!a||!r&&a||!cd(e[n],t[n]))return!1}}return String(e)===String(t)}function ud(e,t){return e.findIndex((e=>cd(e,t)))}const dd=e=>!(!e||!0!==e.__v_isRef),pd=e=>Du(e)?e:null==e?"":Eu(e)||Mu(e)&&(e.toString===Ru||!$u(e.toString))?dd(e)?pd(e.value):JSON.stringify(e,hd,2):String(e),hd=(e,t)=>dd(t)?hd(e,t.value):Au(t)?{[`Map(${t.size})`]:[...t.entries()].reduce(((e,[t,n],r)=>(e[fd(t,r)+" =>"]=n,e)),{})}:Cu(t)?{[`Set(${t.size})`]:[...t.values()].map((e=>fd(e)))}:Iu(t)?fd(t):!Mu(t)||Eu(t)||Bu(t)?t:String(t),fd=(e,t="")=>{var n;return Iu(e)?`Symbol(${null!=(n=e.description)?n:t})`:e};function md(e){return null==e?"initial":"string"==typeof e?""===e?" ":e:String(e)}
|
||||||
|
/**
|
||||||
|
* @vue/reactivity v3.5.21
|
||||||
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||||
|
* @license MIT
|
||||||
|
**/let gd,vd;class bd{constructor(e=!1){this.detached=e,this._active=!0,this._on=0,this.effects=[],this.cleanups=[],this._isPaused=!1,this.parent=gd,!e&&gd&&(this.index=(gd.scopes||(gd.scopes=[])).push(this)-1)}get active(){return this._active}pause(){if(this._active){let e,t;if(this._isPaused=!0,this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].pause();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].pause()}}resume(){if(this._active&&this._isPaused){let e,t;if(this._isPaused=!1,this.scopes)for(e=0,t=this.scopes.length;e<t;e++)this.scopes[e].resume();for(e=0,t=this.effects.length;e<t;e++)this.effects[e].resume()}}run(e){if(this._active){const t=gd;try{return gd=this,e()}finally{gd=t}}}on(){1==++this._on&&(this.prevScope=gd,gd=this)}off(){this._on>0&&0==--this._on&&(gd=this.prevScope,this.prevScope=void 0)}stop(e){if(this._active){let t,n;for(this._active=!1,t=0,n=this.effects.length;t<n;t++)this.effects[t].stop();for(this.effects.length=0,t=0,n=this.cleanups.length;t<n;t++)this.cleanups[t]();if(this.cleanups.length=0,this.scopes){for(t=0,n=this.scopes.length;t<n;t++)this.scopes[t].stop(!0);this.scopes.length=0}if(!this.detached&&this.parent&&!e){const e=this.parent.scopes.pop();e&&e!==this&&(this.parent.scopes[this.index]=e,e.index=this.index)}this.parent=void 0}}}function yd(e){return new bd(e)}function Od(){return gd}function wd(e,t=!1){gd&&gd.cleanups.push(e)}const xd=new WeakSet;class kd{constructor(e){this.fn=e,this.deps=void 0,this.depsTail=void 0,this.flags=5,this.next=void 0,this.cleanup=void 0,this.scheduler=void 0,gd&&gd.active&&gd.effects.push(this)}pause(){this.flags|=64}resume(){64&this.flags&&(this.flags&=-65,xd.has(this)&&(xd.delete(this),this.trigger()))}notify(){2&this.flags&&!(32&this.flags)||8&this.flags||Ed(this)}run(){if(!(1&this.flags))return this.fn();this.flags|=2,Ud(this),Pd(this);const e=vd,t=Rd;vd=this,Rd=!0;try{return this.fn()}finally{$d(this),vd=e,Rd=t,this.flags&=-3}}stop(){if(1&this.flags){for(let e=this.deps;e;e=e.nextDep)Md(e);this.deps=this.depsTail=void 0,Ud(this),this.onStop&&this.onStop(),this.flags&=-2}}trigger(){64&this.flags?xd.add(this):this.scheduler?this.scheduler():this.runIfDirty()}runIfDirty(){Dd(this)&&this.run()}get dirty(){return Dd(this)}}let Sd,_d,Td=0;function Ed(e,t=!1){if(e.flags|=8,t)return e.next=_d,void(_d=e);e.next=Sd,Sd=e}function Ad(){Td++}function Cd(){if(--Td>0)return;if(_d){let e=_d;for(_d=void 0;e;){const t=e.next;e.next=void 0,e.flags&=-9,e=t}}let e;for(;Sd;){let t=Sd;for(Sd=void 0;t;){const n=t.next;if(t.next=void 0,t.flags&=-9,1&t.flags)try{t.trigger()}catch(t){e||(e=t)}t=n}}if(e)throw e}function Pd(e){for(let t=e.deps;t;t=t.nextDep)t.version=-1,t.prevActiveLink=t.dep.activeLink,t.dep.activeLink=t}function $d(e){let t,n=e.depsTail,r=n;for(;r;){const e=r.prevDep;-1===r.version?(r===n&&(n=e),Md(r),Nd(r)):t=r,r.dep.activeLink=r.prevActiveLink,r.prevActiveLink=void 0,r=e}e.deps=t,e.depsTail=n}function Dd(e){for(let t=e.deps;t;t=t.nextDep)if(t.dep.version!==t.version||t.dep.computed&&(Id(t.dep.computed)||t.dep.version!==t.version))return!0;return!!e._dirty}function Id(e){if(4&e.flags&&!(16&e.flags))return;if(e.flags&=-17,e.globalVersion===zd)return;if(e.globalVersion=zd,!e.isSSR&&128&e.flags&&(!e.deps&&!e._dirty||!Dd(e)))return;e.flags|=2;const t=e.dep,n=vd,r=Rd;vd=e,Rd=!0;try{Pd(e);const n=e.fn(e._value);(0===t.version||Wu(n,e._value))&&(e.flags|=128,e._value=n,t.version++)}catch(e){throw t.version++,e}finally{vd=n,Rd=r,$d(e),e.flags&=-3}}function Md(e,t=!1){const{dep:n,prevSub:r,nextSub:a}=e;if(r&&(r.nextSub=a,e.prevSub=void 0),a&&(a.prevSub=r,e.nextSub=void 0),n.subs===e&&(n.subs=r,!r&&n.computed)){n.computed.flags&=-5;for(let e=n.computed.deps;e;e=e.nextDep)Md(e,!0)}t||--n.sc||!n.map||n.map.delete(n.key)}function Nd(e){const{prevDep:t,nextDep:n}=e;t&&(t.nextDep=n,e.prevDep=void 0),n&&(n.prevDep=t,e.nextDep=void 0)}let Rd=!0;const Ld=[];function Bd(){Ld.push(Rd),Rd=!1}function jd(){const e=Ld.pop();Rd=void 0===e||e}function Ud(e){const{cleanup:t}=e;if(e.cleanup=void 0,t){const e=vd;vd=void 0;try{t()}finally{vd=e}}}let zd=0;class Fd{constructor(e,t){this.sub=e,this.dep=t,this.version=t.version,this.nextDep=this.prevDep=this.nextSub=this.prevSub=this.prevActiveLink=void 0}}class Qd{constructor(e){this.computed=e,this.version=0,this.activeLink=void 0,this.subs=void 0,this.map=void 0,this.key=void 0,this.sc=0,this.__v_skip=!0}track(e){if(!vd||!Rd||vd===this.computed)return;let t=this.activeLink;if(void 0===t||t.sub!==vd)t=this.activeLink=new Fd(vd,this),vd.deps?(t.prevDep=vd.depsTail,vd.depsTail.nextDep=t,vd.depsTail=t):vd.deps=vd.depsTail=t,Zd(t);else if(-1===t.version&&(t.version=this.version,t.nextDep)){const e=t.nextDep;e.prevDep=t.prevDep,t.prevDep&&(t.prevDep.nextDep=e),t.prevDep=vd.depsTail,t.nextDep=void 0,vd.depsTail.nextDep=t,vd.depsTail=t,vd.deps===t&&(vd.deps=e)}return t}trigger(e){this.version++,zd++,this.notify(e)}notify(e){Ad();try{for(let e=this.subs;e;e=e.prevSub)e.sub.notify()&&e.sub.dep.notify()}finally{CLine truncated
|
||||||
|
/**
|
||||||
|
* @vue/runtime-core v3.5.21
|
||||||
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||||
|
* @license MIT
|
||||||
|
**/function sh(e,t,n,r){try{return r?e(...r):e()}catch(e){ch(e,t,n)}}function lh(e,t,n,r){if($u(e)){const a=sh(e,t,n,r);return a&&Nu(a)&&a.catch((e=>{ch(e,t,n)})),a}if(Eu(e)){const a=[];for(let o=0;o<e.length;o++)a.push(lh(e[o],t,n,r));return a}}function ch(e,t,n,r=!0){t&&t.vnode;const{errorHandler:a,throwUnhandledErrorInProduction:o}=t&&t.appContext.config||vu;if(t){let r=t.parent;const o=t.proxy,i=`https://vuejs.org/error-reference/#runtime-${n}`;for(;r;){const t=r.ec;if(t)for(let n=0;n<t.length;n++)if(!1===t[n](e,o,i))return;r=r.parent}if(a)return Bd(),sh(a,null,10,[e,o,i]),void jd()}!function(e,t,n,r=!0,a=!1){if(a)throw e;console.error(e)}(e,0,0,r,o)}const uh=[];let dh=-1;const ph=[];let hh=null,fh=0;const mh=Promise.resolve();let gh=null;function vh(e){const t=gh||mh;return e?t.then(this?e.bind(this):e):t}function bh(e){if(!(1&e.flags)){const t=kh(e),n=uh[uh.length-1];!n||!(2&e.flags)&&t>=kh(n)?uh.push(e):uh.splice(function(e){let t=dh+1,n=uh.length;for(;t<n;){const r=t+n>>>1,a=uh[r],o=kh(a);o<e||o===e&&2&a.flags?t=r+1:n=r}return t}(t),0,e),e.flags|=1,yh()}}function yh(){gh||(gh=mh.then(Sh))}function Oh(e){Eu(e)?ph.push(...e):hh&&-1===e.id?hh.splice(fh+1,0,e):1&e.flags||(ph.push(e),e.flags|=1),yh()}function wh(e,t,n=dh+1){for(;n<uh.length;n++){const t=uh[n];if(t&&2&t.flags){if(e&&t.id!==e.uid)continue;uh.splice(n,1),n--,4&t.flags&&(t.flags&=-2),t(),4&t.flags||(t.flags&=-2)}}}function xh(e){if(ph.length){const e=[...new Set(ph)].sort(((e,t)=>kh(e)-kh(t)));if(ph.length=0,hh)return void hh.push(...e);for(hh=e,fh=0;fh<hh.length;fh++){const e=hh[fh];4&e.flags&&(e.flags&=-2),8&e.flags||e(),e.flags&=-2}hh=null,fh=0}}const kh=e=>null==e.id?2&e.flags?-1:1/0:e.id;function Sh(e){try{for(dh=0;dh<uh.length;dh++){const e=uh[dh];!e||8&e.flags||(4&e.flags&&(e.flags&=-2),sh(e,e.i,e.i?15:14),4&e.flags||(e.flags&=-2))}}finally{for(;dh<uh.length;dh++){const e=uh[dh];e&&(e.flags&=-2)}dh=-1,uh.length=0,xh(),gh=null,(uh.length||ph.length)&&Sh()}}let _h=null,Th=null;function Eh(e){const t=_h;return _h=e,Th=e&&e.type.__scopeId||null,t}function Ah(e,t=_h,n){if(!t)return e;if(e._n)return e;const r=(...n)=>{r._d&&ig(-1);const a=Eh(t);let o;try{o=e(...n)}finally{Eh(a),r._d&&ig(1)}return o};return r._n=!0,r._c=!0,r._d=!0,r}function Ch(e,t){if(null===_h)return e;const n=Ug(_h),r=e.dirs||(e.dirs=[]);for(let e=0;e<t.length;e++){let[a,o,i,s=vu]=t[e];a&&($u(a)&&(a={mounted:a,updated:a}),a.deep&&ih(o),r.push({dir:a,instance:n,value:o,oldValue:void 0,arg:i,modifiers:s}))}return e}function Ph(e,t,n,r){const a=e.dirs,o=t&&t.dirs;for(let i=0;i<a.length;i++){const s=a[i];o&&(s.oldValue=o[i].value);let l=s.dir[r];l&&(Bd(),lh(l,n,8,[e.el,s,e,t]),jd())}}const $h=Symbol("_vte"),Dh=e=>e.__isTeleport,Ih=e=>e&&(e.disabled||""===e.disabled),Mh=e=>e&&(e.defer||""===e.defer),Nh=e=>"undefined"!=typeof SVGElement&&e instanceof SVGElement,Rh=e=>"function"==typeof MathMLElement&&e instanceof MathMLElement,Lh=(e,t)=>{const n=e&&e.to;return Du(n)?t?t(n):null:n},Bh={name:"Teleport",__isTeleport:!0,process(e,t,n,r,a,o,i,s,l,c){const{mc:u,pc:d,pbc:p,o:{insert:h,querySelector:f,createText:m,createComment:g}}=c,v=Ih(t.props);let{shapeFlag:b,children:y,dynamicChildren:O}=t;if(null==e){const e=t.el=m(""),c=t.anchor=m("");h(e,n,r),h(c,n,r);const d=(e,t)=>{16&b&&(a&&a.isCE&&(a.ce._teleportTarget=e),u(y,e,t,a,o,i,s,l))},p=()=>{const e=t.target=Lh(t.props,f),n=Fh(e,t,m,h);e&&("svg"!==i&&Nh(e)?i="svg":"mathml"!==i&&Rh(e)&&(i="mathml"),v||(d(e,n),zh(t,!1)))};v&&(d(n,c),zh(t,!0)),Mh(t.props)?(t.el.__isMounted=!1,Em((()=>{p(),delete t.el.__isMounted}),o)):p()}else{if(Mh(t.props)&&!1===e.el.__isMounted)return void Em((()=>{Bh.process(e,t,n,r,a,o,i,s,l,c)}),o);t.el=e.el,t.targetStart=e.targetStart;const u=t.anchor=e.anchor,h=t.target=e.target,m=t.targetAnchor=e.targetAnchor,g=Ih(e.props),b=g?n:h,y=g?u:m;if("svg"===i||Nh(h)?i="svg":("mathml"===i||Rh(h))&&(i="mathml"),O?(p(e.dynamicChildren,O,b,a,o,i,s),$m(e,t,!0)):l||d(e,t,b,y,a,o,i,s,!1),v)g?t.props&&e.props&&t.props.to!==e.props.to&&(t.props.to=e.props.to):jh(t,n,u,c,1);else if((t.props&&t.props.to)!==(e.props&&e.props.to)){const e=t.target=Lh(t.props,f);e&&jh(t,e,null,c,0)}else g&&jh(t,h,m,c,1);zh(t,v)}},remove(e,t,n,{um:r,o:{remove:a}},o){const{shapeFlag:i,children:s,anchor:l,targetStart:c,targetAnchor:u,target:d,props:p}=e;if(d&&(a(c),a(u)),o&&a(l),16&i){const e=o||!Ih(p);for(let a=0;a<s.length;a++){const o=s[a];r(o,t,n,e,!!o.dynamicChildren)}}},move:jh,hydrate:function(e,t,n,r,a,o,{o:{nextSibling:i,parentNode:s,querySelector:l,insert:c,createText:u}},d){function p(e,t,l,c){t.anchor=d(i(e),t,s(e),n,r,a,o),t.targetStart=l,t.targetAnchor=c}const h=t.target=Lh(t.props,l),f=Ih(t.props);if(h){const s=h._lpa||h.firstChild;if(16&t.shapeFlag)if(f)p(e,t,s,s&&i(s));else{t.anchor=i(e);let l=s;for(;l;){if(l&&8===l.nodeType)if("teleport start anchor"===l.data)t.targetStart=l;else if("teleport anchor"===l.data){t.targetAnchor=l,h._lpa=t.targetAnchor&&i(t.targetAnchor);break}l=i(l)}t.targetAnchor||Fh(h,t,u,c),d(s&&i(s),t,h,n,r,a,o)}
Line truncated
|
||||||
|
/**
|
||||||
|
* @vue/runtime-dom v3.5.21
|
||||||
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
||||||
|
* @license MIT
|
||||||
|
**/let Zg;const Hg="undefined"!=typeof window&&window.trustedTypes;if(Hg)try{Zg=Hg.createPolicy("vue",{createHTML:e=>e})}catch(Gb){}const Vg=Zg?e=>Zg.createHTML(e):e=>e,qg="undefined"!=typeof document?document:null,Wg=qg&&qg.createElement("template"),Xg={insert:(e,t,n)=>{t.insertBefore(e,n||null)},remove:e=>{const t=e.parentNode;t&&t.removeChild(e)},createElement:(e,t,n,r)=>{const a="svg"===t?qg.createElementNS("http://www.w3.org/2000/svg",e):"mathml"===t?qg.createElementNS("http://www.w3.org/1998/Math/MathML",e):n?qg.createElement(e,{is:n}):qg.createElement(e);return"select"===e&&r&&null!=r.multiple&&a.setAttribute("multiple",r.multiple),a},createText:e=>qg.createTextNode(e),createComment:e=>qg.createComment(e),setText:(e,t)=>{e.nodeValue=t},setElementText:(e,t)=>{e.textContent=t},parentNode:e=>e.parentNode,nextSibling:e=>e.nextSibling,querySelector:e=>qg.querySelector(e),setScopeId(e,t){e.setAttribute(t,"")},insertStaticContent(e,t,n,r,a,o){const i=n?n.previousSibling:t.lastChild;if(a&&(a===o||a.nextSibling))for(;t.insertBefore(a.cloneNode(!0),n),a!==o&&(a=a.nextSibling););else{Wg.innerHTML=Vg("svg"===r?`<svg>${e}</svg>`:"mathml"===r?`<math>${e}</math>`:e);const a=Wg.content;if("svg"===r||"mathml"===r){const e=a.firstChild;for(;e.firstChild;)a.appendChild(e.firstChild);a.removeChild(e)}t.insertBefore(a,n)}return[i?i.nextSibling:t.firstChild,n?n.previousSibling:t.lastChild]}},Gg="transition",Yg="animation",Kg=Symbol("_vtc"),Jg={name:String,type:String,css:{type:Boolean,default:!0},duration:[String,Number,Object],enterFromClass:String,enterActiveClass:String,enterToClass:String,appearFromClass:String,appearActiveClass:String,appearToClass:String,leaveFromClass:String,leaveActiveClass:String,leaveToClass:String},ev=ku({},Vh,Jg),tv=(e=>(e.displayName="Transition",e.props=ev,e))(((e,{slots:t})=>Fg(Xh,function(e){const t={};for(const n in e)n in Jg||(t[n]=e[n]);if(!1===e.css)return t;const{name:n="v",type:r,duration:a,enterFromClass:o=`${n}-enter-from`,enterActiveClass:i=`${n}-enter-active`,enterToClass:s=`${n}-enter-to`,appearFromClass:l=o,appearActiveClass:c=i,appearToClass:u=s,leaveFromClass:d=`${n}-leave-from`,leaveActiveClass:p=`${n}-leave-active`,leaveToClass:h=`${n}-leave-to`}=e,f=function(e){if(null==e)return null;if(Mu(e))return[av(e.enter),av(e.leave)];{const t=av(e);return[t,t]}}(a),m=f&&f[0],g=f&&f[1],{onBeforeEnter:v,onEnter:b,onEnterCancelled:y,onLeave:O,onLeaveCancelled:w,onBeforeAppear:x=v,onAppear:k=b,onAppearCancelled:S=y}=t,_=(e,t,n,r)=>{e._enterCancelled=r,iv(e,t?u:s),iv(e,t?c:i),n&&n()},T=(e,t)=>{e._isLeaving=!1,iv(e,d),iv(e,h),iv(e,p),t&&t()},E=e=>(t,n)=>{const a=e?k:b,i=()=>_(t,e,n);nv(a,[t,i]),sv((()=>{iv(t,e?l:o),ov(t,e?u:s),rv(a)||cv(t,r,m,i)}))};return ku(t,{onBeforeEnter(e){nv(v,[e]),ov(e,o),ov(e,i)},onBeforeAppear(e){nv(x,[e]),ov(e,l),ov(e,c)},onEnter:E(!1),onAppear:E(!0),onLeave(e,t){e._isLeaving=!0;const n=()=>T(e,t);ov(e,d),e._enterCancelled?(ov(e,p),pv()):(pv(),ov(e,p)),sv((()=>{e._isLeaving&&(iv(e,d),ov(e,h),rv(O)||cv(e,r,g,n))})),nv(O,[e,n])},onEnterCancelled(e){_(e,!1,void 0,!0),nv(y,[e])},onAppearCancelled(e){_(e,!0,void 0,!0),nv(S,[e])},onLeaveCancelled(e){T(e),nv(w,[e])}})}(e),t))),nv=(e,t=[])=>{Eu(e)?e.forEach((e=>e(...t))):e&&e(...t)},rv=e=>!!e&&(Eu(e)?e.some((e=>e.length>1)):e.length>1);function av(e){return(e=>{const t=Du(e)?Number(e):NaN;return isNaN(t)?e:t})(e)}function ov(e,t){t.split(/\s+/).forEach((t=>t&&e.classList.add(t))),(e[Kg]||(e[Kg]=new Set)).add(t)}function iv(e,t){t.split(/\s+/).forEach((t=>t&&e.classList.remove(t)));const n=e[Kg];n&&(n.delete(t),n.size||(e[Kg]=void 0))}function sv(e){requestAnimationFrame((()=>{requestAnimationFrame(e)}))}let lv=0;function cv(e,t,n,r){const a=e._endId=++lv,o=()=>{a===e._endId&&r()};if(null!=n)return setTimeout(o,n);const{type:i,timeout:s,propCount:l}=function(e,t){const n=window.getComputedStyle(e),r=e=>(n[e]||"").split(", "),a=r(`${Gg}Delay`),o=r(`${Gg}Duration`),i=uv(a,o),s=r(`${Yg}Delay`),l=r(`${Yg}Duration`),c=uv(s,l);let u=null,d=0,p=0;t===Gg?i>0&&(u=Gg,d=i,p=o.length):t===Yg?c>0&&(u=Yg,d=c,p=l.length):(d=Math.max(i,c),u=d>0?i>c?Gg:Yg:null,p=u?u===Gg?o.length:l.length:0);return{type:u,timeout:d,propCount:p,hasTransform:u===Gg&&/\b(?:transform|all)(?:,|$)/.test(r(`${Gg}Property`).toString())}}(e,t);if(!i)return r();const c=i+"end";let u=0;const d=()=>{e.removeEventListener(c,p),o()},p=t=>{t.target===e&&++u>=l&&d()};setTimeout((()=>{u<l&&d()}),s+1),e.addEventListener(c,p)}function uv(e,t){for(;e.length<t.length;)e=e.concat(e);return Math.max(...t.map(((t,n)=>dv(t)+dv(e[n]))))}function dv(e){return"auto"===e?0:1e3*Number(e.slice(0,-1).replace(",","."))}function pv(){return document.body.offsetHeight}const hv=Symbol("_vod"),fv=Symbol("_vsh"),mv={name:"show",beforeMount(e,{value:t},{transition:n}){e[hv]="none"===e.style.display?"":e.style.display,n&&t?n.beforeEnter(e):gv(e,t)},mounted(e,{value:t},{transition:n}){n&&t&&n.enter(e)},updated(e,{value:t,oldValue:n},{transition:r}){!t!=!n&&(r?t?(r.beforeEnter(e),gv(e,!0),r.
Line truncated
|
||||||
|
/*!
|
||||||
|
* vue-router v4.6.2
|
||||||
|
* (c) 2025 Eduardo San Martin Morote
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
const obe=()=>{},ibe=Array.isArray;function sbe(e,t){return(e.aliasOf||e)===(t.aliasOf||t)}function lbe(e,t){return ibe(e)?cbe(e,t):ibe(t)?cbe(t,e):e===t}function cbe(e,t){return ibe(t)?e.length===t.length&&e.every(((e,n)=>e===t[n])):1===e.length&&e[0]===t}const ube=Symbol(""),dbe=Symbol("");
|
||||||
|
/*!
|
||||||
|
* vue-router v4.6.2
|
||||||
|
* (c) 2025 Eduardo San Martin Morote
|
||||||
|
* @license MIT
|
||||||
|
*/function pbe(e){const t=dm(ube),n=dm(dbe),r=zg((()=>{const n=Hp(e.to);return t.resolve(n)})),a=zg((()=>{const{matched:e}=r.value,{length:t}=e,a=e[t-1],o=n.matched;if(!a||!o.length)return-1;const i=o.findIndex(sbe.bind(null,a));if(i>-1)return i;const s=fbe(e[t-2]);return t>1&&fbe(a)===s&&o[o.length-1].path!==s?o.findIndex(sbe.bind(null,e[t-2])):i})),o=zg((()=>a.value>-1&&function(e,t){for(const n in t){const r=t[n],a=e[n];if("string"==typeof r){if(r!==a)return!1}else if(!ibe(a)||a.length!==r.length||r.some(((e,t)=>e!==a[t])))return!1}return!0}(n.params,r.value.params))),i=zg((()=>a.value>-1&&a.value===n.matched.length-1&&function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(!lbe(e[n],t[n]))return!1;return!0}(n.params,r.value.params)));return{route:r,href:zg((()=>r.value.href)),isActive:o,isExactActive:i,navigate:function(n={}){if(function(e){if(!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey||e.defaultPrevented||void 0!==e.button&&0!==e.button)){if(e.currentTarget&&e.currentTarget.getAttribute){const t=e.currentTarget.getAttribute("target");if(/\b_blank\b/i.test(t))return}return e.preventDefault&&e.preventDefault(),!0}}(n)){const n=t[Hp(e.replace)?"replace":"push"](Hp(e.to)).catch(obe);return e.viewTransition&&"undefined"!=typeof document&&"startViewTransition"in document&&document.startViewTransition((()=>n)),n}return Promise.resolve()}}}const hbe=nf({name:"RouterLink",compatConfig:{MODE:3},props:{to:{type:[String,Object],required:!0},replace:Boolean,activeClass:String,exactActiveClass:String,custom:Boolean,ariaCurrentValue:{type:String,default:"page"},viewTransition:Boolean},useLink:pbe,setup(e,{slots:t}){const n=Ap(pbe(e)),{options:r}=dm(ube),a=zg((()=>({[mbe(e.activeClass,r.linkActiveClass,"router-link-active")]:n.isActive,[mbe(e.exactActiveClass,r.linkExactActiveClass,"router-link-exact-active")]:n.isExactActive})));return()=>{const r=t.default&&(1===(o=t.default(n)).length?o[0]:o);var o;return e.custom?r:Fg("a",{"aria-current":n.isExactActive?e.ariaCurrentValue:null,href:n.href,onClick:n.navigate,class:a.value},r)}}});function fbe(e){return e?e.aliasOf?e.aliasOf.path:e.path:""}const mbe=(e,t,n)=>null!=e?e:null!=t?t:n;Vs({uid:es().brand(),name:es().optional().default("Default Environment"),color:es().optional().default("#FFFFFF"),value:es().default(""),isDefault:Es().optional()}),qie.domEventHandlers({keydown(e,t){if("Backspace"===e.key){const{state:n}=t,{from:r,to:a}=n.selection.main;if(0===r&&a===n.doc.length)return t.dispatch({changes:{from:0,to:n.doc.length},selection:{anchor:0}}),e.preventDefault(),!0;if(r===a&&r>0&&"}}"===n.doc.sliceString(r-2,r))return t.dispatch({changes:{from:r-2,to:a},selection:{anchor:r-2}}),e.preventDefault(),!0}return!1}});const gbe=nf({__name:"HttpMethod",props:{isSquare:{type:Boolean,default:!1},method:{},isEditable:{type:Boolean,default:!1}},emits:["change"],setup(e,{emit:t}){const n=e,r=t,a=zg((()=>aV(n.method))),o=Object.entries(rV).map((([e])=>({id:e,label:e.toUpperCase(),color:aV(e).colorClass}))),i=zg({get:()=>o.find((({id:e})=>e===n.method)),set:e=>e?.id&&r("change",e.id)}),s=Xw({base:"text-center font-code text-3xs justify-center items-center flex",variants:{isSquare:{true:"px-2.5 whitespace-nowrap font-bold border-r h-fit m-auto",false:"rounded-full"},isEditable:{true:"http-bg-gradient rounded-md border border-r",false:"cursor-auto"}}}),l=zg((()=>a.value.short));return(e,t)=>e.isEditable?(ag(),cg(Hp(a9),{key:0,modelValue:i.value,"onUpdate:modelValue":t[0]||(t[0]=e=>i.value=e),class:"font-code scalar-client mt-1 text-sm",options:Hp(o)},{default:Ah((()=>[fg("div",{class:od(["h-full",{"pointer-events-none":!e.isEditable}])},[fg("button",{class:od(["relative h-full",Hp(Gw)(Hp(s)({isSquare:e.isSquare,isEditable:e.isEditable}),a.value.colorClass)]),type:"button"},[fg("span",null,pd(l.value),1)],2)],2)])),_:1},8,["modelValue","options"])):(ag(),lg("div",{key:1,class:od(["relative gap-1 whitespace-nowrap",Hp(Gw)(Hp(s)({isSquare:e.isSquare,isEditable:e.isEditable}),a.value.colorClass)]),type:"button"},pd(a.value.short),3))}}),vbe=Kee(gbe,[["__scopeId","data-v-076b14a1"]]),bbe=(e,t=2)=>e>1e3?(e/1e3).toFixed(t)+"s":e+"ms",ybe=Vs({description:es().optional()}),Obe=Vs({uid:HH.brand(),nameKey:es().optional().default("")}),wbe=ybe.extend({type:cl("apiKey"),name:es().optional().default(""),in:sl(["query","header","cookie"]).optional().default("header").catch("header")}),xbe=Vs({value:es().default("")}),kbe=wbe.merge(Obe).merge(xbe),Sbe=ybe.extend({type:cl("http"),scheme:es().toLowerCase().pipe(sl(["basic","bearer"])).optional().default("basic"),bearerFormat:Ws([cl("JWT"),es()]).optional().default("JWT")}),_be=Vs({username:es().default(""),password:es().default(""),token:es().default("")}),Tbe=Sbe.merge(Obe).merge(_be),Ebe=ybe.extend({type:cl("openIdConnect"),openIdConnectUrl:es().optional().default("")}),Abe=Ebe.merge(Obe),Cbe=es().default(""),Pbe=es().default(""),$be=Vs({refreshUrl:es().optional().default(""),scopes:nl(es(),es().optionalLine truncated
|
||||||
|
/*!
|
||||||
|
* tabbable 6.2.0
|
||||||
|
* @license MIT, https://github.com/focus-trap/tabbable/blob/master/LICENSE
|
||||||
|
*/;var rIe=["input:not([inert])","select:not([inert])","textarea:not([inert])","a[href]:not([inert])","button:not([inert])","[tabindex]:not(slot):not([inert])","audio[controls]:not([inert])","video[controls]:not([inert])",'[contenteditable]:not([contenteditable="false"]):not([inert])',"details>summary:first-of-type:not([inert])","details:not([inert])"],aIe=rIe.join(","),oIe="undefined"==typeof Element,iIe=oIe?function(){}:Element.prototype.matches||Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector,sIe=!oIe&&Element.prototype.getRootNode?function(e){var t;return null==e||null===(t=e.getRootNode)||void 0===t?void 0:t.call(e)}:function(e){return null==e?void 0:e.ownerDocument},lIe=function e(t,n){var r;void 0===n&&(n=!0);var a=null==t||null===(r=t.getAttribute)||void 0===r?void 0:r.call(t,"inert");return""===a||"true"===a||n&&t&&e(t.parentNode)},cIe=function(e,t,n){if(lIe(e))return[];var r=Array.prototype.slice.apply(e.querySelectorAll(aIe));return t&&iIe.call(e,aIe)&&r.unshift(e),r.filter(n)},uIe=function e(t,n,r){for(var a=[],o=Array.from(t);o.length;){var i=o.shift();if(!lIe(i,!1))if("SLOT"===i.tagName){var s=i.assignedElements(),l=e(s.length?s:i.children,!0,r);r.flatten?a.push.apply(a,l):a.push({scopeParent:i,candidates:l})}else{iIe.call(i,aIe)&&r.filter(i)&&(n||!t.includes(i))&&a.push(i);var c=i.shadowRoot||"function"==typeof r.getShadowRoot&&r.getShadowRoot(i),u=!lIe(c,!1)&&(!r.shadowRootFilter||r.shadowRootFilter(i));if(c&&u){var d=e(!0===c?i.children:c.children,!0,r);r.flatten?a.push.apply(a,d):a.push({scopeParent:i,candidates:d})}else o.unshift.apply(o,i.children)}}return a},dIe=function(e){return!isNaN(parseInt(e.getAttribute("tabindex"),10))},pIe=function(e){if(!e)throw new Error("No node provided");return e.tabIndex<0&&(/^(AUDIO|VIDEO|DETAILS)$/.test(e.tagName)||function(e){var t,n=null==e||null===(t=e.getAttribute)||void 0===t?void 0:t.call(e,"contenteditable");return""===n||"true"===n}(e))&&!dIe(e)?0:e.tabIndex},hIe=function(e,t){return e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex},fIe=function(e){return"INPUT"===e.tagName},mIe=function(e){var t=e.getBoundingClientRect(),n=t.width,r=t.height;return 0===n&&0===r},gIe=function(e,t){return!(t.disabled||lIe(t)||function(e){return fIe(e)&&"hidden"===e.type}(t)||function(e,t){var n=t.displayCheck,r=t.getShadowRoot;if("hidden"===getComputedStyle(e).visibility)return!0;var a=iIe.call(e,"details>summary:first-of-type")?e.parentElement:e;if(iIe.call(a,"details:not([open]) *"))return!0;if(n&&"full"!==n&&"legacy-full"!==n){if("non-zero-area"===n)return mIe(e)}else{if("function"==typeof r){for(var o=e;e;){var i=e.parentElement,s=sIe(e);if(i&&!i.shadowRoot&&!0===r(i))return mIe(e);e=e.assignedSlot?e.assignedSlot:i||s===e.ownerDocument?i:s.host}e=o}if(function(e){var t,n,r,a,o=e&&sIe(e),i=null===(t=o)||void 0===t?void 0:t.host,s=!1;if(o&&o!==e)for(s=!!(null!==(n=i)&&void 0!==n&&null!==(r=n.ownerDocument)&&void 0!==r&&r.contains(i)||null!=e&&null!==(a=e.ownerDocument)&&void 0!==a&&a.contains(e));!s&&i;){var l,c,u;s=!(null===(c=i=null===(l=o=sIe(i))||void 0===l?void 0:l.host)||void 0===c||null===(u=c.ownerDocument)||void 0===u||!u.contains(i))}return s}(e))return!e.getClientRects().length;if("legacy-full"!==n)return!0}return!1}(t,e)||function(e){return"DETAILS"===e.tagName&&Array.prototype.slice.apply(e.children).some((function(e){return"SUMMARY"===e.tagName}))}(t)||function(e){if(/^(INPUT|BUTTON|SELECT|TEXTAREA)$/.test(e.tagName))for(var t=e.parentElement;t;){if("FIELDSET"===t.tagName&&t.disabled){for(var n=0;n<t.children.length;n++){var r=t.children.item(n);if("LEGEND"===r.tagName)return!!iIe.call(t,"fieldset[disabled] *")||!r.contains(e)}return!0}t=t.parentElement}return!1}(t))},vIe=function(e,t){return!(function(e){return function(e){return fIe(e)&&"radio"===e.type}(e)&&!function(e){if(!e.name)return!0;var t,n=e.form||sIe(e),r=function(e){return n.querySelectorAll('input[type="radio"][name="'+e+'"]')};if("undefined"!=typeof window&&void 0!==window.CSS&&"function"==typeof window.CSS.escape)t=r(window.CSS.escape(e.name));else try{t=r(e.name)}catch(e){return console.error("Looks like you have a radio button with a name attribute containing invalid CSS selector characters and need the CSS.escape polyfill: %s",e.message),!1}var a=function(e,t){for(var n=0;n<e.length;n++)if(e[n].checked&&e[n].form===t)return e[n]}(t,e.form);return!a||a===e}(e)}(t)||pIe(t)<0||!gIe(e,t))},bIe=function(e){var t=parseInt(e.getAttribute("tabindex"),10);return!!(isNaN(t)||t>=0)},yIe=function e(t){var n=[],r=[];return t.forEach((function(t,a){var o=!!t.scopeParent,i=o?t.scopeParent:t,s=function(e,t){var n=pIe(e);return n<0&&t&&!dIe(e)?0:n}(i,o),l=o?e(t.candidates):i;0===s?o?n.push.apply(n,l):n.push(i):r.push({documentOrder:a,tabIndex:s,item:t,isScope:o,content:l})})),r.sort(hIe).reduce((function(e,t){return t.isScope?e.push.apply(e,t.content):e.push(t.content),e}),[]).concat(n)},OIe=function(e,t){if(t=t||{},!e)throw new Error(Line truncated
|
||||||
|
/*!
|
||||||
|
* focus-trap 7.6.2
|
||||||
|
* @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE
|
||||||
|
*/function kIe(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function SIe(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t);if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _Ie(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function TIe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?_Ie(Object(n),!0).forEach((function(t){SIe(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):_Ie(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var EIe=function(e){return"Tab"===(null==e?void 0:e.key)||9===(null==e?void 0:e.keyCode)},AIe=function(e){return EIe(e)&&!e.shiftKey},CIe=function(e){return EIe(e)&&e.shiftKey},PIe=function(e){return setTimeout(e,0)},$Ie=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return"function"==typeof e?e.apply(void 0,n):e},DIe=function(e){return e.target.shadowRoot&&"function"==typeof e.composedPath?e.composedPath()[0]:e.target},IIe=[],MIe=function(e,t){var n,r=(null==t?void 0:t.document)||document,a=(null==t?void 0:t.trapStack)||IIe,o=TIe({returnFocusOnDeactivate:!0,escapeDeactivates:!0,delayInitialFocus:!0,isKeyForward:AIe,isKeyBackward:CIe},t),i={containers:[],containerGroups:[],tabbableGroups:[],nodeFocusedBeforeActivation:null,mostRecentlyFocusedNode:null,active:!1,paused:!1,delayInitialFocusTimer:void 0,recentNavEvent:void 0},s=function(e,t,n){return e&&void 0!==e[t]?e[t]:o[n||t]},l=function(e,t){var n="function"==typeof(null==t?void 0:t.composedPath)?t.composedPath():void 0;return i.containerGroups.findIndex((function(t){var r=t.container,a=t.tabbableNodes;return r.contains(e)||(null==n?void 0:n.includes(r))||a.find((function(t){return t===e}))}))},c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.hasFallback,a=void 0!==n&&n,i=t.params,s=void 0===i?[]:i,l=o[e];if("function"==typeof l&&(l=l.apply(void 0,function(e){return function(e){if(Array.isArray(e))return kIe(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return kIe(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?kIe(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}(s))),!0===l&&(l=void 0),!l){if(void 0===l||!1===l)return l;throw new Error("`".concat(e,"` was specified but was not a node, or did not return a node"))}var c=l;if("string"==typeof l){try{c=r.querySelector(l)}catch(t){throw new Error("`".concat(e,'` appears to be an invalid selector; error="').concat(t.message,'"'))}if(!c&&!a)throw new Error("`".concat(e,"` as selector refers to no known node"))}return c},u=function(){var e=c("initialFocus",{hasFallback:!0});if(!1===e)return!1;if(void 0===e||e&&!xIe(e,o.tabbableOptions))if(l(r.activeElement)>=0)e=r.activeElement;else{var t=i.tabbableGroups[0];e=t&&t.firstTabbableNode||c("fallbackFocus")}else null===e&&(e=c("fallbackFocus"));if(!e)throw new Error("Your focus-trap needs to have at least one focusable element");return e},d=function(){if(i.containerGroups=i.containers.map((function(e){var t=function(e,t){var n;return n=(t=t||{}).getShadowRoot?uIe([e],t.includeContainer,{filter:vIe.bind(null,t),flatten:!1,getShadowRoot:t.getShadowRoot,shadowRootFilter:bIe}):cIe(e,t.includeContainer,vIe.bind(null,t)),yIe(n)}(e,o.tabbableOptions),n=function(e,t){return(t=t||{}).getShadowRoot?uIe([e],t.includeContainer,{filter:gIe.bind(null,t),flatten:!0,getShadowRoot:t.getShadowRoot}):cIe(e,t.includeContainer,gIe.bind(null,t))}(e,o.tabbableOptions),r=t.length>0?t[0]:void 0,a=t.length>0?t[t.length-1]:void 0,i=n.find((function(e){return OIe(e)})),s=n.slice().reverse().find((function(e){return OIe(e)})),l=!!t.find((function(e){return pIe(e)>0}));return{container:e,tabbableNodes:t,focusableNodes:n,posTabIndexesFound:l,firstTabbableNode:r,lastTabbableNode:a,firstDomTabbableNode:i,lastDomTabbableNode:s,nextTabbableNode:function(e){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],a=t.indexOf(e);return a<0?r?n.slice(n.indexOf(e)+1).find((function(e){return OIe(e)})):n.slice(0,n.indexOf(eLine truncated
|
||||||
|
//# sourceMappingURL=/sm/7ea4dd333ea74cfb08ca3f0085f970e2739df4317d6e214dff3b18d444729e07.map
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<title>{{DOC_TITLE}}</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script id="api-reference" data-url="{{BASE_URI}}/doc.json" data-configuration='{"showDeveloperTools":"never"}'></script>
|
||||||
|
<script src="{{BASE_URI}}/api-reference.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
// Package ratelimit 提供入口独占的内存与借用原生 Redis 的限流执行器。
|
||||||
|
package ratelimit
|
||||||
|
|
||||||
|
import "context"
|
||||||
|
|
||||||
|
// Config 描述当前主体的令牌桶配置,时间单位沿用秒。
|
||||||
|
type Config struct {
|
||||||
|
Key string `json:"key" dc:"可信主体及路由组合的限流键"`
|
||||||
|
Total int `json:"total" dc:"令牌桶容量"`
|
||||||
|
Rate int `json:"rate" dc:"每个同步周期补充的令牌数"`
|
||||||
|
TimeInterval int64 `json:"time_interval" dc:"Redis 周期秒数;内存后端保持固定每秒补充"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Limiter 是消费方共用的额度判定与重置能力,不负责业务 Key 或客户端生命周期。
|
||||||
|
type Limiter interface {
|
||||||
|
AllowN(context.Context, *Config, int) (bool, error)
|
||||||
|
Reset(context.Context, *Config) error
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ Limiter = (*Memory)(nil)
|
||||||
|
_ Limiter = (*Redis)(nil)
|
||||||
|
_ Limiter = Disabled{}
|
||||||
|
)
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package ratelimit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Disabled 表示入口明确禁用流控时的无状态实现。
|
||||||
|
type Disabled struct{}
|
||||||
|
|
||||||
|
// AllowN 在关闭流控时始终放行。
|
||||||
|
// 入参:ctx 为调用上下文,cfg 为额度配置,count 为消耗令牌数。
|
||||||
|
// 返回:固定允许且无错误。
|
||||||
|
func (Disabled) AllowN(ctx context.Context, cfg *Config, count int) (bool, error) {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset 在关闭流控时无需清理状态。
|
||||||
|
// 入参:ctx 为调用上下文,cfg 为主体配置。
|
||||||
|
// 返回:固定 nil。
|
||||||
|
func (Disabled) Reset(ctx context.Context, cfg *Config) error { return nil }
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package ratelimit
|
||||||
|
|
||||||
|
const (
|
||||||
|
// CodeMemoryLimiterInput 表示内存限流判定缺少主体配置,供独立组件诊断。
|
||||||
|
CodeMemoryLimiterInput = 900901
|
||||||
|
// CodeMemoryLimiterReset 表示内存限流重置缺少主体配置,供独立组件诊断。
|
||||||
|
CodeMemoryLimiterReset = 900902
|
||||||
|
// CodeRedisInput 表示分布式额度判定缺少主体配置。
|
||||||
|
CodeRedisInput = 900903
|
||||||
|
// CodeRedisAllow 表示分布式额度判定执行失败。
|
||||||
|
CodeRedisAllow = 900904
|
||||||
|
// CodeRedisResetInput 表示分布式额度重置缺少主体配置。
|
||||||
|
CodeRedisResetInput = 900905
|
||||||
|
// CodeRedisReset 表示分布式额度重置执行失败。
|
||||||
|
CodeRedisReset = 900906
|
||||||
|
)
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package ratelimit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"git.zhangdeman.cn/zhangdeman/ginframework/internal/testutil/redisserver"
|
||||||
|
)
|
||||||
|
|
||||||
|
// TestRedisLimiterKeepsQuotaAndReset 验证原周期、桶容量和重置行为在原生连接上保持不变。
|
||||||
|
func TestRedisLimiterKeepsQuotaAndReset(t *testing.T) {
|
||||||
|
var (
|
||||||
|
client = redisserver.New(t, 3)
|
||||||
|
limiter = NewRedis(client)
|
||||||
|
cfg = &Config{Key: "owner", Total: 1, Rate: 1, TimeInterval: 3600}
|
||||||
|
ctx = context.Background()
|
||||||
|
)
|
||||||
|
if allowed, err := limiter.AllowN(ctx, cfg, 1); err != nil || !allowed {
|
||||||
|
t.Fatalf("first allowance: %v %v", allowed, err)
|
||||||
|
}
|
||||||
|
if allowed, err := limiter.AllowN(ctx, cfg, 1); err != nil || allowed {
|
||||||
|
t.Fatalf("quota exceeded: %v %v", allowed, err)
|
||||||
|
}
|
||||||
|
if err := limiter.Reset(ctx, cfg); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if allowed, err := limiter.AllowN(ctx, cfg, 1); err != nil || !allowed {
|
||||||
|
t.Fatalf("reset failed: %v %v", allowed, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TestMemoryLimitersRemainIndependent 验证独立入口不再共享可变额度,重置仍可重新获得令牌。
|
||||||
|
func TestMemoryLimitersRemainIndependent(t *testing.T) {
|
||||||
|
var (
|
||||||
|
first, second = NewMemory(), NewMemory()
|
||||||
|
cfg = &Config{Key: "same", Total: 1, Rate: 1, TimeInterval: 3600}
|
||||||
|
ctx = context.Background()
|
||||||
|
)
|
||||||
|
if allow, _ := first.AllowN(ctx, cfg, 1); !allow {
|
||||||
|
t.Fatal("initial quota missing")
|
||||||
|
}
|
||||||
|
if allow, _ := first.AllowN(ctx, cfg, 1); allow {
|
||||||
|
t.Fatal("quota was not consumed")
|
||||||
|
}
|
||||||
|
if allow, _ := second.AllowN(ctx, cfg, 1); !allow {
|
||||||
|
t.Fatal("independent entry shares quota")
|
||||||
|
}
|
||||||
|
if err := first.Reset(ctx, cfg); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if allow, _ := first.AllowN(ctx, cfg, 1); !allow {
|
||||||
|
t.Fatal("reset failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package ratelimit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
fault "git.zhangdeman.cn/zhangdeman/ginframework/internal/failure"
|
||||||
|
|
||||||
|
"golang.org/x/time/rate"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Memory 由单次入口持有内存额度,避免不同入口共用可变限流状态。
|
||||||
|
type Memory struct {
|
||||||
|
lock sync.Mutex `dc:"保护主体额度的建立及重置"`
|
||||||
|
entries map[string]*rate.Limiter `dc:"按可信主体键组织的令牌桶"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// AllowN 保留既有内存实现按秒速率与桶容量判定的行为。
|
||||||
|
// 入参:ctx 为调用上下文,input 为可信额度参数,count 为消耗令牌数。
|
||||||
|
// 返回:令牌足够时返回 true;缺少配置时返回内部错误。
|
||||||
|
func (m *Memory) AllowN(ctx context.Context, input *Config, count int) (bool, error) {
|
||||||
|
var (
|
||||||
|
limiter *rate.Limiter
|
||||||
|
)
|
||||||
|
if input == nil {
|
||||||
|
return false, fault.WrapContext(ctx, CodeMemoryLimiterInput, "memory rate limit configuration is missing", errors.New("rate limit input is nil"))
|
||||||
|
}
|
||||||
|
m.lock.Lock()
|
||||||
|
limiter = m.entries[input.Key]
|
||||||
|
if limiter == nil {
|
||||||
|
limiter = rate.NewLimiter(rate.Limit(input.Rate), input.Total)
|
||||||
|
m.entries[input.Key] = limiter
|
||||||
|
}
|
||||||
|
m.lock.Unlock()
|
||||||
|
return limiter.AllowN(time.Now(), count), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset 清除当前入口持有的主体额度。
|
||||||
|
// 入参:ctx 为调用上下文,input 为需要重置的可信主体参数。
|
||||||
|
// 返回:配置为空时返回内部错误,其余情况返回 nil。
|
||||||
|
func (m *Memory) Reset(ctx context.Context, input *Config) error {
|
||||||
|
if input == nil {
|
||||||
|
return fault.WrapContext(ctx, CodeMemoryLimiterReset, "memory rate limit reset configuration is missing", errors.New("rate limit reset input is nil"))
|
||||||
|
}
|
||||||
|
m.lock.Lock()
|
||||||
|
defer m.lock.Unlock()
|
||||||
|
delete(m.entries, input.Key)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewMemory 创建属于当前应用入口的独立内存额度表。
|
||||||
|
// 返回:不共享可变状态的内存限流器。
|
||||||
|
func NewMemory() *Memory { return &Memory{entries: make(map[string]*rate.Limiter)} }
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
// Package ratelimit 维护可复用的原生限流执行器,不持有动态连接注册器。
|
||||||
|
package ratelimit
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
fault "git.zhangdeman.cn/zhangdeman/ginframework/internal/failure"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis_rate/v10"
|
||||||
|
"github.com/redis/go-redis/v9"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Redis 复用入口创建的 Redis 客户端执行 GCRA,不管理客户端生命周期。
|
||||||
|
type Redis struct {
|
||||||
|
limiter *redis_rate.Limiter `dc:"绑定既有客户端的原生分布式额度算法"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRedis 创建分布式额度适配器。
|
||||||
|
// 入参:client 为已完成启动探测的原生客户端。
|
||||||
|
// 返回:没有可变包级状态的限流器。
|
||||||
|
func NewRedis(client *redis.Client) *Redis { return &Redis{limiter: redis_rate.NewLimiter(client)} }
|
||||||
|
|
||||||
|
// AllowN 沿用既有额度、秒级周期及允许结果语义。
|
||||||
|
// 入参:ctx 为取消上下文,cfg 为额度,count 为消耗令牌数。
|
||||||
|
// 返回:是否允许;底层失败保留原始原因。
|
||||||
|
func (r *Redis) AllowN(ctx context.Context, cfg *Config, count int) (bool, error) {
|
||||||
|
var (
|
||||||
|
result *redis_rate.Result
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if cfg == nil {
|
||||||
|
return false, fault.WrapContext(ctx, CodeRedisInput, "Redis rate limit input is required", errors.New("rate limit input is nil"))
|
||||||
|
}
|
||||||
|
if cfg.Total <= 0 || cfg.Rate <= 0 {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
result, err = r.limiter.AllowN(ctx, cfg.Key, redis_rate.Limit{Rate: cfg.Rate, Period: time.Duration(cfg.TimeInterval) * time.Second, Burst: cfg.Total}, count)
|
||||||
|
if err != nil {
|
||||||
|
return false, fault.WrapContext(ctx, CodeRedisAllow, "evaluate Redis rate limit failed", err)
|
||||||
|
}
|
||||||
|
return result.Allowed > 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset 清除当前主体的额度。
|
||||||
|
// 入参:ctx 为取消上下文,cfg 为可信主体配置。
|
||||||
|
// 返回:清理失败时保留错误链。
|
||||||
|
func (r *Redis) Reset(ctx context.Context, cfg *Config) error {
|
||||||
|
if cfg == nil {
|
||||||
|
return fault.WrapContext(ctx, CodeRedisResetInput, "Redis rate limit reset input is required", errors.New("rate limit reset input is nil"))
|
||||||
|
}
|
||||||
|
return fault.WrapContext(ctx, CodeRedisReset, "reset Redis rate limit failed", r.limiter.Reset(ctx, cfg.Key))
|
||||||
|
}
|
||||||
@@ -88,7 +88,7 @@ func run(formatCheck bool, architecture bool) error {
|
|||||||
invalid = invalid || strings.Contains(strings.Split(imported, "/")[0], ".")
|
invalid = invalid || strings.Contains(strings.Split(imported, "/")[0], ".")
|
||||||
case strings.HasPrefix(directory, "logger"):
|
case strings.HasPrefix(directory, "logger"):
|
||||||
invalid = invalid || (strings.HasPrefix(imported, module+"/") && !strings.HasPrefix(imported, module+"/logger/") && imported != module+"/diagnostic")
|
invalid = invalid || (strings.HasPrefix(imported, module+"/") && !strings.HasPrefix(imported, module+"/logger/") && imported != module+"/diagnostic")
|
||||||
case strings.HasPrefix(directory, "database") || strings.HasPrefix(directory, "redis") || directory == "httpclient":
|
case strings.HasPrefix(directory, "database") || strings.HasPrefix(directory, "redis") || directory == "httpclient" || directory == "ratelimit":
|
||||||
invalid = invalid || strings.HasPrefix(imported, "github.com/gin-gonic/") || imported == module+"/http" || strings.HasPrefix(imported, module+"/http/")
|
invalid = invalid || strings.HasPrefix(imported, "github.com/gin-gonic/") || imported == module+"/http" || strings.HasPrefix(imported, module+"/http/")
|
||||||
case directory == "config":
|
case directory == "config":
|
||||||
invalid = invalid || strings.HasPrefix(imported, module+"/http") || strings.HasPrefix(imported, module+"/database") || strings.HasPrefix(imported, module+"/redis")
|
invalid = invalid || strings.HasPrefix(imported, module+"/http") || strings.HasPrefix(imported, module+"/database") || strings.HasPrefix(imported, module+"/redis")
|
||||||
|
|||||||