glass

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 16 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommonContext

func CommonContext(c *gin.Context) context.Context

CommonContext 函数把【*gin.Context】转换成【context.Context】

func EditableContext

func EditableContext(c *gin.Context) lang.Context

EditableContext 函数把【*gin.Context】转换成【lang.Context】

func GinContext

func GinContext(cc context.Context) *gin.Context

GinContext 函数把【context.Context】转换成【*gin.Context】

Types

type Connector

type Connector interface {

	// 打开连接
	Open() (EngineConnection, error)
}

Connector 是服务连接器的接口

type Container

type Container struct {
	Name         string
	Server       *Server
	Connectors   []Connector
	Services     []*WebContext
	ContentTypes ContentTypeManager
	IndexPages   string
	AppContext   application.Context
	// contains filtered or unexported fields
}

Container 表示一个web容器(gin-glass)

type ContentTypeManager

type ContentTypeManager interface {
	Find(pathname string) string
}

type Controller

type Controller interface {
	Init(ec EngineConnection) error
}

Controller 接口表示一个gin-glass控制器

type ControllerFunc added in v0.0.14

type ControllerFunc func(ec EngineConnection) error

ControllerFunc 提供一个面向函数的控制器接口

type DefaultContentTypeManager

type DefaultContentTypeManager struct {
	AppContext      application.Context
	TypesProperties string
	// contains filtered or unexported fields
}

func (*DefaultContentTypeManager) Find

func (inst *DefaultContentTypeManager) Find(name string) string

Find 根据文件名查找相应的content-type

type DefaultRestController

type DefaultRestController struct {
}

type EngineConnection

type EngineConnection interface {
	io.Closer // 用于关闭连接

	// 等待工作者循环退出
	Join() error

	// 运行工作者循环
	Run() error

	//  映射到新的路径
	RequestMapping(path string) EngineConnection

	// 注册过滤器
	Filter(order int, handler gin.HandlerFunc)

	// 注册处理器
	Handle(method string, path string, handler gin.HandlerFunc)

	// 注册 error 处理器
	HandleNoMethod(handler gin.HandlerFunc)

	// 注册 error 处理器
	HandleNoResource(handler gin.HandlerFunc)
}

EngineConnection 表示与gin.Engine 之间的连接

type ErrorController

type ErrorController struct {

	// public
	ResourcePath string
	ContentType  string
	Status       int

	Container *Container
	// contains filtered or unexported fields
}

func (*ErrorController) Init

func (inst *ErrorController) Init(ec EngineConnection) error

type GroupController added in v0.0.14

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

GroupController 将一组 ControllerFunc 封装成一个 Controller 对象

func (*GroupController) AddController added in v0.0.14

func (inst *GroupController) AddController(ctr Controller)

AddController 添加一个 Controller 到group

func (*GroupController) AddFunction added in v0.0.14

func (inst *GroupController) AddFunction(fn ControllerFunc)

AddFunction 添加一个func到group

func (*GroupController) Init added in v0.0.14

func (inst *GroupController) Init(ec EngineConnection) error

Init 初始化

type HTTPConnector

type HTTPConnector struct {
	GinMode string

	Host   string
	Port   int
	Enable bool
}

HTTPConnector 是一个基本的http连接器,提供不加密的http服务

func (*HTTPConnector) Open

func (inst *HTTPConnector) Open() (EngineConnection, error)

Open 打开连接

type HTTPSConnector

type HTTPSConnector struct {
	Host   string
	Port   int
	Enable bool

	GinMode string

	CertificateFile string
	PrivateKeyFile  string
}

HTTPSConnector 是一个加密的https连接器,提供安全的https服务

func (*HTTPSConnector) Open

func (inst *HTTPSConnector) Open() (EngineConnection, error)

Open 打开连接

type LocalFileSystemController

type LocalFileSystemController struct {
}

type Server

type Server struct {
	Container *Container
}

Server 表示 gin-glass 服务器对象

func (*Server) Loop

func (inst *Server) Loop() error

Loop 执行服务器主循环

func (*Server) Start

func (inst *Server) Start() error

Start 启动服务器

func (*Server) Stop

func (inst *Server) Stop() error

Stop 停止服务器

type StaticWebResourcesController

type StaticWebResourcesController struct {
	Root      string     // 这是一个资源路径,指向 static-www 文件夹       `inject:"${web.static.root}"`
	Container *Container `inject:"#gin-web-container"`
}

func (*StaticWebResourcesController) Init

type WebContext

type WebContext struct {
	Container   *Container
	ContextPath string
	Controllers []Controller
}

WebContext 表示一个web上下文(service)

func (*WebContext) Init

func (inst *WebContext) Init(ec EngineConnection) error

Init 控制器初始化

func (*WebContext) MainController

func (inst *WebContext) MainController() Controller

MainController 取上下文的主控制器

Jump to

Keyboard shortcuts

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