registry

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 6

README

registry

Register时prefix中替换规则

%v:funcName 或者 structName/methodName
%s:structName
%m:funcName 或者 methodName

开发中

Documentation

Index

Constants

View Source
const (
	PathMatchParam string = ":"
	PathMatchVague string = "*"
)

Variables

This section is empty.

Functions

func FuncName

func FuncName(i interface{}) (fname string)

func IsExported

func IsExported(name string) bool

func Join added in v0.0.3

func Join(paths ...string) (r string)

func RouteName added in v0.0.3

func RouteName(name string) string

func ValueOf

func ValueOf(i interface{}) reflect.Value

Types

type Node

type Node struct {
	Service *Service
	// contains filtered or unexported fields
}

func (*Node) Binder

func (this *Node) Binder() interface{}

func (*Node) Call

func (this *Node) Call(args ...interface{}) (r []reflect.Value)

func (*Node) IsFunc

func (this *Node) IsFunc() bool

IsFunc 判断是func

func (*Node) IsMethod

func (this *Node) IsMethod() bool

IsMethod 对象中的方法

func (*Node) IsStruct added in v0.0.3

func (this *Node) IsStruct() bool

IsStruct 仅仅是一个还未解析的对象

func (*Node) Method

func (this *Node) Method() (fun interface{})

func (*Node) Name added in v0.0.3

func (this *Node) Name() string

func (*Node) Route added in v0.0.3

func (this *Node) Route() string

func (*Node) Value

func (this *Node) Value() reflect.Value

type Registry

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

func New

func New(router *Router) *Registry

func (*Registry) Get

func (this *Registry) Get(name string) (srv *Service, ok bool)

func (*Registry) Has

func (this *Registry) Has(name string) (ok bool)

func (*Registry) Len

func (this *Registry) Len() int

func (*Registry) Match

func (this *Registry) Match(paths ...string) (node *Node, ok bool)

Match 通过路径匹配Route,path必须是使用 Registry.Clean()处理后的

func (*Registry) Merge added in v0.0.3

func (this *Registry) Merge(r *Registry) (err error)

func (*Registry) Nodes added in v0.0.5

func (this *Registry) Nodes(f func(node *Node) bool)

Nodes 遍历所有节点

func (*Registry) Range added in v0.0.3

func (this *Registry) Range(f func(service *Service) bool)

Range 遍历所有服务

func (*Registry) Router added in v0.0.3

func (this *Registry) Router() *Router

func (*Registry) Service

func (this *Registry) Service(name string) *Service

Service GET OR CREATE

type Router added in v0.0.3

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

func NewRouter added in v0.0.3

func NewRouter() *Router

func (*Router) Handle added in v0.0.3

func (this *Router) Handle() interface{}

func (*Router) Match added in v0.0.3

func (this *Router) Match(paths ...string) (nodes []*Router)

/s/:id/update /s/123

func (*Router) Params added in v0.0.3

func (this *Router) Params(paths ...string) map[string]string

func (*Router) Register added in v0.0.3

func (this *Router) Register(handle interface{}, paths ...string) (err error)

Register 注册协议

func (*Router) Route added in v0.0.3

func (this *Router) Route() (r []string)

func (*Router) String added in v0.0.3

func (this *Router) String() string

type Service

type Service struct {
	Handler   interface{}         //自定义 Filter等方法
	Formatter func(string) string //格式化对象和方法名,默认强制小写
	// contains filtered or unexported fields
}

func NewService

func NewService(name string, router *Router) *Service

func (*Service) Merge added in v0.0.3

func (this *Service) Merge(s *Service) (err error)

func (*Service) Name

func (this *Service) Name() string

func (*Service) Paths

func (this *Service) Paths() (r []string)

func (*Service) Prefix

func (this *Service) Prefix() string

func (*Service) Range added in v0.0.3

func (this *Service) Range(f func(*Node) bool)

func (*Service) Register

func (this *Service) Register(i interface{}, prefix ...string) error

Register 服务注册

func (*Service) RegisterFun

func (this *Service) RegisterFun(i interface{}, prefix ...string) error

func (*Service) RegisterStruct

func (this *Service) RegisterStruct(i interface{}, prefix ...string) error

RegisterStruct 注册一组handle

Jump to

Keyboard shortcuts

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