gw

package
v0.0.0-...-911e024 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2024 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ShortURLLen   = 8
	ShortURLTTL   = 30 * 365 * 24 * time.Hour // 约30年
	ShortURLRoute = "/utils/s/"
)
View Source
const (
	IndexFile = "index.html"
)

Variables

This section is empty.

Functions

func GetFullURLFromGinCtx

func GetFullURLFromGinCtx(c *gin.Context) string

GetFullURLFromGinCtx 从 Gin 上下文中获取完整的 URL, 处理 X-Original-URI, X-Forwarded-Proto 和 X-Forwarded-Host 头 网关代理场景下,可能进行 redirect 操作,此时可以通过设置 X-Original-URI 头来指定原始 URI

func LarkEventHandler

func LarkEventHandler(c *gin.Context)

func PerformanceMonitor

func PerformanceMonitor() gin.HandlerFunc

func RegRouter

func RegRouter(router *gin.Engine, db *gorm.DB, iamCli *authcli.Cli, APIGroup string, staticFilePath string)

func RegisterCallbacks

func RegisterCallbacks(router gin.IRouter)

func RegisterRoutes

func RegisterRoutes(router gin.IRouter, db *gorm.DB, iamCli *authcli.Cli)

RegisterRoutes - routers all in one todo: using rpc

func SetupShortURLRoutes

func SetupShortURLRoutes(router *gin.Engine)

SetupShortURLRoutes 设置短网址相关路由

func SetupStaticFileServer

func SetupStaticFileServer(router gin.IRouter, staticDir string, apiGroup string)

SetupStaticFileServer 配置静态文件服务和前端路由处理

Types

type Callback

type Callback[T any] struct {
	// challenge validate
	Type      string `json:"type,omitempty"`
	Challenge string `json:"challenge,omitempty"`

	Schema string `json:"schema"`
	Header Header `json:"header"`
	Event  T      `json:"event"`
}

type ChallengeResp

type ChallengeResp struct {
	Code      int    `json:"code,omitempty"`
	Msg       string `json:"msg,omitempty"`
	Challenge string `json:"challenge,omitempty"`
}
type Header struct {
	EventID   string `json:"event_id"`
	EventType string `json:"event_type"`
}

type ShortURLEntry

type ShortURLEntry struct {
	OriginalURL string
	ExpiresAt   time.Time
}

Jump to

Keyboard shortcuts

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