goweber

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2025 License: MIT Imports: 19 Imported by: 0

README

goweber

介绍

{以下是 Gitee 平台说明,您可以替换此简介 Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 https://gitee.com/enterprises}

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Apper

type Apper struct {

	// 緩存器
	Cache *Cacher
	// contains filtered or unexported fields
}

Apper 是应用程序的主结构体,包含路由映射、配置信息、端口、日志等信息

func New

func New() *Apper

New 创建并初始化一个新的Apper实例

func (*Apper) Close

func (this *Apper) Close()

Close 关闭应用程序资源,包括日志文件和消息通道

func (*Apper) Get

func (this *Apper) Get(path string, f http.HandlerFunc, mid ...MiddlewareFunc)

Get 注册GET请求的路由处理函数

func (*Apper) GetClientIP

func (this *Apper) GetClientIP(r *http.Request) string

GetClientIP 获取客户端真实IP地址

func (*Apper) Logger

func (this *Apper) Logger()

Logger 处理日志记录,监听消息通道并将日志写入文件或控制台

func (*Apper) Post

func (this *Apper) Post(path string, f http.HandlerFunc, mid ...MiddlewareFunc)

Post 注册POST请求的路由处理函数

func (*Apper) Route

func (this *Apper) Route(method string, path string, f http.HandlerFunc, mid ...MiddlewareFunc)

Route 注册指定HTTP方法的路由处理函数

func (*Apper) Run

func (this *Apper) Run()

Run 启动HTTP服务器

func (*Apper) RunTLS

func (this *Apper) RunTLS(certFile, keyFile string)

RunTLS 启动HTTPS服务器

func (*Apper) ServeHTTP

func (this *Apper) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP 实现http.Handler接口,处理HTTP请求

func (*Apper) SetCache

func (this *Apper) SetCache()

SetCache 缓存设置

func (*Apper) SetConfig

func (this *Apper) SetConfig()

SetConfig 从config.ini文件中读取配置信息

func (*Apper) SetLimit

func (this *Apper) SetLimit()

SetLimit 設置限流

func (*Apper) SetLog

func (this *Apper) SetLog()

SetLog 根据配置设置日志记录器

func (*Apper) SetPort

func (this *Apper) SetPort()

SetPort 从配置中设置服务器端口,默认为8080

func (*Apper) Use

func (this *Apper) Use(middleware ...MiddlewareFunc)

全局中間件處理

type Cacher

type Cacher struct {
	// contains filtered or unexported fields
}

func NewCacher

func NewCacher(m int64) *Cacher

* 新建緩存,m為空間大小,單位 m

func (*Cacher) IsCache

func (this *Cacher) IsCache(w http.ResponseWriter, r *http.Request) bool

* 判斷緩存是否存在,存在則返回緩存數據

func (*Cacher) SetCache

func (this *Cacher) SetCache(r *http.Request, m int64, data string)

* 根據url定義緩存時間和緩存數據,m為分鐘

func (*Cacher) Size

func (this *Cacher) Size() int64

* 獲取占用空間大小

type Configer

type Configer struct {
	// contains filtered or unexported fields
}

func (*Configer) Get

func (this *Configer) Get(title string, key string) string

func (*Configer) ReadFile

func (this *Configer) ReadFile() error

func (*Configer) SetFile

func (this *Configer) SetFile(f *os.File)

type FileUploader

type FileUploader struct {
	MaxSize      int64
	AllowedTypes []string
	SavePath     string
	FieldName    string // 添加单文件字段名
	FieldNames   string // 添加多文件字段名
	Keyword      string // 添加文件名关键字
}

func NewFileUploader

func NewFileUploader(maxSize int64, allowedTypes []string, savePath string) *FileUploader

func (*FileUploader) HandleUpload

func (f *FileUploader) HandleUpload(r *http.Request) ([]string, error)

HandleUpload 修改为支持批量文件上传

type Jwter

type Jwter struct {
	Rint    int
	Rstr    string
	Exphour int
	Version string
	Key     string
}

func NewJwter

func NewJwter() *Jwter

func (*Jwter) Decode

func (this *Jwter) Decode(token string) (string, error)

func (*Jwter) Encode

func (this *Jwter) Encode() (string, error)

func (*Jwter) GetArr

func (this *Jwter) GetArr(tokenstr string) ([]string, error)

func (*Jwter) GetJoin

func (this *Jwter) GetJoin(key string, exp string, code string) (string, error)

func (*Jwter) OneToTwo

func (this *Jwter) OneToTwo(val string) string

func (*Jwter) Validate

func (this *Jwter) Validate(token string) error

type MiddlewareFunc

type MiddlewareFunc func(r *http.Request) error

中間件類型

type Token

type Token struct {
	Id   string
	Exp  string
	Code string
}

Jump to

Keyboard shortcuts

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