api

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 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 允许的来源域名列表

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 模块汇入点 每新增一个子模块,在此文件追加一行匿名导入即可
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 移植 star-history(github.com/Mubelotix/star-history) 的 SVG 星标历史图表生成能力,仅保留 /svg 图像接口。
Package starhistory 移植 star-history(github.com/Mubelotix/star-history) 的 SVG 星标历史图表生成能力,仅保留 /svg 图像接口。

Jump to

Keyboard shortcuts

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