api

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version 为构建时通过 -ldflags 注入的版本号,如 "v1.2.3" 未注入时默认为 "dev"

Functions

func RegisterController

func RegisterController(c Controller)

RegisterController 收集所有模块的注册函数

func SetupRouter

func SetupRouter(mode string, trustedProxies []string, allowedOrigins []string) *gin.Engine

SetupRouter 统一加载所有已注册的 Controller mode: debug | release | test,在创建 Engine 前设置 trustedProxies: 反向代理可信 IP 列表,影响 c.ClientIP() allowedOrigins: CORS 允许的来源域名列表

func Shutdown added in v1.11.0

func Shutdown()

Shutdown 在进程退出前触发所有模块的可选收尾逻辑: 模块只需额外实现 Shutdown() 方法(如 hitcount 将内存计数刷入数据库) 就会被调用。

Types

type Controller

type Controller interface {
	// Register 注册路由到给定的 Group(已带 /api/<moduleName> 前缀)
	Register(r *gin.RouterGroup)
	// ModuleName 返回模块名,用作路由前缀
	ModuleName() string
	// Enabled 返回模块是否启用;未启用时跳过路由注册
	Enabled() bool
}

Controller 接口:所有独立的 API 模块都需实现此接口

Directories

Path Synopsis
Package modules 模块汇入点 每新增一个子模块,在此文件追加一行匿名导入即可
Package modules 模块汇入点 每新增一个子模块,在此文件追加一行匿名导入即可
hitcount
Package hitcount 提供访问计数(hits)模块,参考 dwyl/hits 的用法, 但不沿用其数据库设计:计数按「键值对」存储,键为路径、值为累计次数 (表 hitcount_hits,主键 path)。
Package hitcount 提供访问计数(hits)模块,参考 dwyl/hits 的用法, 但不沿用其数据库设计:计数按「键值对」存储,键为路径、值为累计次数 (表 hitcount_hits,主键 path)。
pathproxy
Package pathproxy 路径代理模块:把 /api/pathproxy/<path> 的请求按配置 规则转发到对应上游 URL,支持精确路径与末尾 "*" 通配。
Package pathproxy 路径代理模块:把 /api/pathproxy/<path> 的请求按配置 规则转发到对应上游 URL,支持精确路径与末尾 "*" 通配。
siteinfo
Package siteinfo 网页信息抓取(site-info-api 移植):
Package siteinfo 网页信息抓取(site-info-api 移植):
starhistory
Package starhistory 提供 SVG 星标历史图表接口(GET /api/star_history/svg, 参数语义与 star-history 对齐)。
Package starhistory 提供 SVG 星标历史图表接口(GET /api/star_history/svg, 参数语义与 star-history 对齐)。

Jump to

Keyboard shortcuts

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