glass

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 8 Imported by: 26

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector interface {
	Connect(h http.Handler) (NetworkConnection, error)
	Enabled() bool
}

Connector 是服务连接器的接口

type Container

type Container interface {
	GetName() string                     //  `inject:"${server.name}"`
	GetConnectors() []Connector          //  `inject:".web-server-connector"`
	GetContexts() []WebContext           //  `inject:".web-context"`
	GetContentTypes() ContentTypeManager //  `inject:"#gin-web-content-types"`
	GetIndexPages() string               //  `inject:"${web.static.index-pages}"`
	GetIndexPageNames() []string         //  `inject:"${web.static.index-pages}"`

	Shutdown() error
}

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

type ContentTypeManager

type ContentTypeManager interface {
	Find(pathname string) string
}

ContentTypeManager ...

type Controller

type Controller interface {
	Init(ec EngineConnection) error
}

Controller 接口表示一个gin-glass控制器。 可以通过【inject:".rest-controller"】 或【inject:".static-web-controller"】注入

type ControllerFunc added in v0.0.14

type ControllerFunc func(ec EngineConnection) error

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

type DefaultContentTypeManager

type DefaultContentTypeManager struct {
	markup.Component `id:"gin-web-content-types"`

	AppContext      application.Context `inject:"context"`
	TypesProperties string              `inject:"${web.static.content-types-properties}"`
	// contains filtered or unexported fields
}

DefaultContentTypeManager ...

func (*DefaultContentTypeManager) Find

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

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

type EngineConnection

type EngineConnection interface {

	// 取 WebContext
	GetWebContext() WebContext

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

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

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

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

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

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

type ErrorController

type ErrorController struct {
	markup.Component `class:"static-web-controller"`

	ResourcePath string              `inject:"${web.error-page.resource}"`
	ContentType  string              `inject:"${web.error-page.content-type}"`
	Status       int                 `inject:"${web.error-page.status}"`
	Container    Container           `inject:"#gin-web-container"`
	Context      application.Context `inject:"context"`
	// contains filtered or unexported fields
}

ErrorController ...

func (*ErrorController) Init

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

Init ...

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 Interceptor added in v0.1.1

type Interceptor interface {

	// input: 目标handler , output: 目标的代理
	Intercept(h gin.HandlerFunc) gin.HandlerFunc
}

Interceptor ...

type InterceptorRegistration added in v0.1.1

type InterceptorRegistration struct {
	Name        string
	Order       int
	Interceptor Interceptor
}

InterceptorRegistration ...

type InterceptorRegistry added in v0.1.1

type InterceptorRegistry interface {
	GetRegistrationList() []*InterceptorRegistration
}

InterceptorRegistry ... 通过【inject:".rest-interceptor-registry"】 或者【inject:".static-web-interceptor-registry"】注入

type MainResponder added in v0.1.2

type MainResponder interface {
	Responder
	TargetResponderName() string
}

MainResponder ... 【inject:"#glass-main-responder"】

type NetworkConnection added in v0.1.0

type NetworkConnection interface {

	// 退出工作循环
	Shutdown() error

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

NetworkConnection 表示 gin.Engine 与网络之间的连接

type Responder added in v0.1.2

type Responder interface {
	Send(resp *Response)
}

Responder ...

type ResponderRegistration added in v0.1.2

type ResponderRegistration struct {
	Name      string
	Responder Responder
}

ResponderRegistration ...

type ResponderRegistry added in v0.1.2

type ResponderRegistry interface {
	GetRegistrationList() []*ResponderRegistration
}

ResponderRegistry ... 【inject:".glass-responder-registry"】

type Response added in v0.1.2

type Response struct {
	Context *gin.Context
	Data    interface{}
	Status  int
	Error   error
}

Response ...

type StaticWebResourcesController

type StaticWebResourcesController struct {
	markup.Component `class:"static-web-controller"`

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

StaticWebResourcesController ...

func (*StaticWebResourcesController) Init

Init ...

type WebContext

type WebContext interface {
	GetContextID() string
	GetContainer() Container
	GetContextPath() string
	GetControllers() []Controller
	GetInterceptors() []InterceptorRegistry
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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