Documentation
¶
Index ¶
- Constants
- func GetRouteMeta[T any](m map[string]any, key string) T
- type ACCESS_MODE
- type DescribeEndpointRequest
- type Endpoint
- type QueryEndpointRequest
- type RegistryEndpointRequest
- type RouteEntry
- func (e *RouteEntry) AddRequiredRole(roles ...string) *RouteEntry
- func (e *RouteEntry) HasRequiredRole() bool
- func (e *RouteEntry) IsRequireRole(target string) bool
- func (e *RouteEntry) LoadMeta(meta map[string]any)
- func (e *RouteEntry) SetExtensionFromMap(m map[string]string) *RouteEntry
- func (e *RouteEntry) SetLabel(value string) *RouteEntry
- func (e *RouteEntry) SetRequiredAuth(v bool) *RouteEntry
- func (e *RouteEntry) SetRequiredCode(v bool) *RouteEntry
- func (e *RouteEntry) SetRequiredPerm(v bool) *RouteEntry
- func (e *RouteEntry) UniquePath() string
- type Service
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" )
View Source
const (
AppName = "endpoint"
)
Variables ¶
This section is empty.
Functions ¶
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 `json:"route_entry" bson:",inline" validate:"required"` }
Endpoint Service's features
func NewEndpoint ¶
func NewEndpoint() *Endpoint
func (*Endpoint) SetRouteEntry ¶
func (u *Endpoint) SetRouteEntry(v RouteEntry) *Endpoint
type QueryEndpointRequest ¶
type QueryEndpointRequest struct {
*request.PageRequest
}
func NewQueryEndpointRequest ¶
func NewQueryEndpointRequest() *QueryEndpointRequest
type RegistryEndpointRequest ¶
type RegistryEndpointRequest struct {
Items []*RouteEntry `json:"items"`
}
func NewRegistryEndpointRequest ¶
func NewRegistryEndpointRequest() *RegistryEndpointRequest
func (*RegistryEndpointRequest) Validate ¶
func (r *RegistryEndpointRequest) Validate() error
type RouteEntry ¶
type RouteEntry struct { // 该功能属于那个服务 Service string `json:"service" bson:"service" validate:"required,lte=64" gorm:"column:service;type:varchar(100);index"` // 服务那个版本的功能 Version string `json:"version" bson:"version" validate:"required,lte=64" gorm:"column:version;type:varchar(100)"` // 资源名称 Resource string `json:"resource" bson:"resource" gorm:"column:resource;type:varchar(100);index"` // 资源操作 Action string `json:"action" bson:"action" gorm:"column:action;type:varchar(100);index"` // 读或者写 AccessMode ACCESS_MODE `json:"access_mode" bson:"access_mode" gorm:"column:access_mode;type:tinyint(1);index"` // 操作标签 ActionLabel string `json:"action_label" gorm:"column:action_label;type:varchar(200);index"` // 函数名称 FunctionName string `json:"function_name" bson:"function_name" gorm:"column:function_name;type:varchar(100)"` // HTTP path 用于自动生成http api Path string `json:"path" bson:"path" gorm:"column:path;type:varchar(200);index"` // HTTP method 用于自动生成http api Method string `json:"method" bson:"method" gorm:"column:method;type:varchar(100);index"` // 接口说明 Description string `json:"description" bson:"description" gorm:"column:description;type:text"` // 是否校验用户身份 (acccess_token 校验) RequiredAuth bool `json:"required_auth" bson:"required_auth" gorm:"column:required_auth;type:tinyint(1)"` // 验证码校验(开启双因子认证需要) (code 校验) RequiredCode bool `json:"required_code" bson:"required_code" gorm:"column:required_code;type:tinyint(1)"` // 开启鉴权 RequiredPerm bool `json:"required_perm" bson:"required_perm" gorm:"column:required_perm;type:tinyint(1)"` // ACL模式下, 允许的通过的身份标识符, 比如角色, 用户类型之类 RequiredRole []string `json:"required_role" bson:"required_role" gorm:"column:required_role;serializer:json;type:json"` // 是否开启操作审计, 开启后这次操作将被记录 RequiredAudit bool `json:"required_audit" bson:"required_audit" gorm:"column:required_audit;type:tinyint(1)"` // 名称空间不能为空 RequiredNamespace bool `json:"required_namespace" bson:"required_namespace" gorm:"column:required_namespace;type:tinyint(1)"` // 扩展信息 Extras map[string]string `json:"extras" bson:"extras" gorm:"column:extras;serializer:json;type:json"` }
Entry 路由条目
func NewEntryFromRestRequest ¶
func NewEntryFromRestRequest(req *restful.Request) *RouteEntry
func NewEntryFromRestRoute ¶
func NewEntryFromRestRoute(route restful.RouteReader) *RouteEntry
func NewRouteEntry ¶
func NewRouteEntry() *RouteEntry
func (*RouteEntry) AddRequiredRole ¶
func (e *RouteEntry) AddRequiredRole(roles ...string) *RouteEntry
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
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
Click to show internal directories.
Click to hide internal directories.