xweb

package
v0.0.0-...-bb138a7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultName = "default"
)

Variables

This section is empty.

Functions

func Listen

func Listen()

Listen 监听所有

Types

type Config

type Config struct {
	Addr              string        `json:"addr"`                         // Addr 本地监听地址
	Https             Https         `json:"https" mapstructure:"https"`   // Https Https配置
	Mode              string        `json:"mode"`                         // Mode 运行模式
	Agent             string        `json:"agent"`                        // Agent 服务agent
	RootPath          string        `json:"rootPath"`                     // RootPath 网站根目录
	Static            Static        `json:"static" mapstructure:"static"` // Static 静态资源
	DumpRouter        bool          `json:"dumpRouter"`                   // DumpRouter 是否打印路由
	KeepAlive         bool          `json:"keepAlive"`                    // KeepAlive 是否开启Keep-Alive功能
	ReadTimeout       time.Duration `json:"readTimeout"`                  // ReadTimeout 请求读取超时时间
	WriteTimeout      time.Duration `json:"writeTimeout"`                 // WriteTimeout 数据返回写入超时时间
	IdleTimeout       time.Duration `json:"idleTimeout"`                  // IdleTimeout 仅当Keep-Alive开启时有效,请求闲置时间
	MaxHeaderBytes    int           `json:"maxHeaderBytes"`               // MaxHeaderBytes 请求Header大小限制(Byte)
	ClientMaxBodySize int64         `json:"clientMaxBodySize"`            // ClientMaxBodySize 客户端最大Body上传限制大小,影响文件上传大小(Byte)
	FormParsingMemory int64         `json:"formParsingMemory"`            // FormParsingMemory 解析表单时的缓冲区大小(Byte)

	Cors   middleware.CorsOption `json:"cors" mapstructure:"cors"`     // Cors 跨域配置
	Access xlog.Config           `json:"access" mapstructure:"access"` // Access 请求访问日志
	Error  xlog.Config           `json:"error" mapstructure:"error"`   // Error 错误日志
}

Config 配置

func NewConfig

func NewConfig() Config

NewConfig 返回默认配置

type Https

type Https struct {
	Addr         string `json:"addr" yaml:"addr"`                 // Addr https地址
	KeyPath      string `json:"keyPath" yaml:"keyPath"`           // KeyPath https证书key路径
	CertPath     string `json:"certPath" yaml:"certPath"`         // CertPath https证书路径
	AutoRedirect bool   `json:"autoRedirect" yaml:"autoRedirect"` // AutoRedirect http自动跳转到https
}

Https https配置

type Plugin

type Plugin interface {
	Name() string            // Name 插件名称
	Author() string          // Author 插件作者
	Version() string         // Version 插件版本
	Description() string     // Description 插件描述
	Install(s *Server) error // Install 服务启动时执行插件安装

}

type Server

type Server struct {
	*gin.Engine
	// contains filtered or unexported fields
}

func New

func New(name string, config ...Config) *Server

New 返回server实例

func (*Server) Config

func (s *Server) Config() Config

Config 获取配置

func (*Server) Install

func (s *Server) Install() error

Install 安装插件

func (*Server) Listen

func (s *Server) Listen()

Listen 监听服务

func (*Server) Plugin

func (s *Server) Plugin(plugin ...Plugin)

Plugin 添加插件

func (*Server) Plugins

func (s *Server) Plugins() []Plugin

Plugins 获取所有的插件

func (*Server) Start

func (s *Server) Start() error

Start 启动服务

type Static

type Static struct {
	Fs   map[string]string `json:"fs" yaml:"fs"`
	Dir  map[string]string `json:"dir" yaml:"dir"`
	File map[string]string `json:"file" yaml:"file"`
}

Static 静态资源

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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