endpoint

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ACCESS_MODE_READ = iota
	ACCESS_MODE_READ_WRITE
)
View Source
const (
	META_REQUIRED_AUTH_KEY      = "required_auth"
	META_REQUIRED_CODE_KEY      = "required_code"
	META_REQUIRED_PERM_KEY      = "required_perm"
	META_REQUIRED_ROLE_KEY      = "required_role"
	META_REQUIRED_AUDIT_KEY     = "required_audit"
	META_REQUIRED_NAMESPACE_KEY = "required_namespace"
	META_RESOURCE_KEY           = "resource"
	META_ACTION_KEY             = "action"
)
View Source
const (
	AppName = "endpoint"
)

Variables

This section is empty.

Functions

func GetRouteMeta

func GetRouteMeta[T any](m map[string]any, key string) T

func IsEndpointExist added in v0.0.5

func IsEndpointExist(set *types.Set[*Endpoint], target *Endpoint) bool

Types

type ACCESS_MODE

type ACCESS_MODE uint8

type DescribeEndpointRequest

type DescribeEndpointRequest struct {
	apps.GetRequest
}

func NewDescribeEndpointRequest

func NewDescribeEndpointRequest() *DescribeEndpointRequest

type Endpoint

type Endpoint struct {
	// 基础数据
	apps.ResourceMeta
	// 路由条目信息
	RouteEntry `bson:",inline" validate:"required"`
}

Endpoint Service's features

func NewEndpoint

func NewEndpoint() *Endpoint

func (*Endpoint) IsMatched added in v0.0.5

func (e *Endpoint) IsMatched(service, method, path string) bool

func (*Endpoint) SetRouteEntry

func (u *Endpoint) SetRouteEntry(v RouteEntry) *Endpoint

func (*Endpoint) String added in v0.0.10

func (e *Endpoint) String() string

func (*Endpoint) TableName

func (e *Endpoint) TableName() string

type QueryEndpointRequest

type QueryEndpointRequest struct {
	Services []string `form:"services" json:"serivces"`
}

func NewQueryEndpointRequest

func NewQueryEndpointRequest() *QueryEndpointRequest

func (*QueryEndpointRequest) IsMatchAllService added in v0.0.5

func (r *QueryEndpointRequest) IsMatchAllService() bool

func (*QueryEndpointRequest) WithService added in v0.0.5

func (r *QueryEndpointRequest) WithService(services ...string) *QueryEndpointRequest

type RegistryEndpointRequest

type RegistryEndpointRequest struct {
	Items []*RouteEntry `json:"items"`
}

func NewRegistryEndpointRequest

func NewRegistryEndpointRequest() *RegistryEndpointRequest

func (*RegistryEndpointRequest) AddItem added in v0.0.3

func (*RegistryEndpointRequest) Validate

func (r *RegistryEndpointRequest) Validate() error

type RouteEntry

type RouteEntry struct {
	// 该功能属于那个服务
	UUID string `json:"uuid" bson:"uuid" gorm:"column:uuid;type:varchar(100);uniqueIndex" optional:"true" description:"路由UUID"`
	// 该功能属于那个服务
	Service string `` /* 129-byte string literal not displayed */
	// 服务那个版本的功能
	Version string `` /* 139-byte string literal not displayed */
	// 资源名称
	Resource string `json:"resource" bson:"resource" gorm:"column:resource;type:varchar(100);index" description:"资源名称"`
	// 资源操作
	Action string `json:"action" bson:"action" gorm:"column:action;type:varchar(100);index" description:"资源操作"`
	// 读或者写
	AccessMode ACCESS_MODE `` /* 128-byte string literal not displayed */
	// 操作标签
	ActionLabel string `json:"action_label" gorm:"column:action_label;type:varchar(200);index" optional:"true" description:"资源标签"`
	// 函数名称
	FunctionName string `` /* 131-byte string literal not displayed */
	// HTTP path 用于自动生成http api
	Path string `json:"path" bson:"path" gorm:"column:path;type:varchar(200);index" description:"接口的路径"`
	// HTTP method 用于自动生成http api
	Method string `json:"method" bson:"method" gorm:"column:method;type:varchar(100);index" description:"接口的方法"`
	// 接口说明
	Description string `json:"description" bson:"description" gorm:"column:description;type:text" optional:"true" description:"接口说明"`
	// 是否校验用户身份 (acccess_token 校验)
	RequiredAuth bool `` /* 163-byte string literal not displayed */
	// 验证码校验(开启双因子认证需要) (code 校验)
	RequiredCode bool `` /* 174-byte string literal not displayed */
	// 开启鉴权
	RequiredPerm bool `` /* 128-byte string literal not displayed */
	// ACL模式下, 允许的通过的身份标识符, 比如角色, 用户类型之类
	RequiredRole []string `` /* 207-byte string literal not displayed */
	// 是否开启操作审计, 开启后这次操作将被记录
	RequiredAudit bool `` /* 178-byte string literal not displayed */
	// 名称空间不能为空
	RequiredNamespace bool `` /* 155-byte string literal not displayed */
	// 扩展信息
	Extras map[string]string `json:"extras" bson:"extras" gorm:"column:extras;serializer:json;type:json" optional:"true" description:"扩展信息"`
}

Entry 路由条目, service-method-path

func NewEntryFromRestRequest

func NewEntryFromRestRequest(req *restful.Request) *RouteEntry

func NewEntryFromRestRoute

func NewEntryFromRestRoute(route restful.Route) *RouteEntry

func NewEntryFromRestRouteReader added in v0.0.3

func NewEntryFromRestRouteReader(route restful.RouteReader) *RouteEntry

func NewEntryFromRestfulContainer added in v0.0.3

func NewEntryFromRestfulContainer(c *restful.Container) (entries []*RouteEntry)

func NewRouteEntry

func NewRouteEntry() *RouteEntry

func (*RouteEntry) AddRequiredRole

func (e *RouteEntry) AddRequiredRole(roles ...string) *RouteEntry

func (*RouteEntry) BuildUUID added in v0.0.3

func (e *RouteEntry) BuildUUID() *RouteEntry

service-method-path

func (*RouteEntry) HasRequiredRole

func (e *RouteEntry) HasRequiredRole() bool

UniquePath todo

func (*RouteEntry) IsRequireRole

func (e *RouteEntry) IsRequireRole(target string) bool

func (*RouteEntry) LoadMeta

func (e *RouteEntry) LoadMeta(meta map[string]any)

func (*RouteEntry) SetExtensionFromMap

func (e *RouteEntry) SetExtensionFromMap(m map[string]string) *RouteEntry

func (*RouteEntry) SetLabel

func (e *RouteEntry) SetLabel(value string) *RouteEntry

func (*RouteEntry) SetRequiredAuth

func (e *RouteEntry) SetRequiredAuth(v bool) *RouteEntry

func (*RouteEntry) SetRequiredCode

func (e *RouteEntry) SetRequiredCode(v bool) *RouteEntry

func (*RouteEntry) SetRequiredPerm

func (e *RouteEntry) SetRequiredPerm(v bool) *RouteEntry

func (*RouteEntry) UniquePath

func (e *RouteEntry) UniquePath() string

UniquePath todo

type Service

type Service interface {
	// 查询API接口列表
	QueryEndpoint(context.Context, *QueryEndpointRequest) (*types.Set[*Endpoint], error)
	// 查询API接口详情
	DescribeEndpoint(context.Context, *DescribeEndpointRequest) (*Endpoint, error)
	// 注册API接口
	RegistryEndpoint(context.Context, *RegistryEndpointRequest) (*types.Set[*Endpoint], error)
}

func GetService

func GetService() Service

Directories

Path Synopsis
api
gin
impl

Jump to

Keyboard shortcuts

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