RuleGo RuleGo
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文
🏠首页
  • 快速入门
  • 规则链
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 可视化
  • RuleGo-Server
  • RuleGo-MCP-Server
  • AOP
  • 触发器
  • 高级主题
  • 性能
  • 标准组件
  • 扩展组件
  • 自定义组件
  • 组件市场
  • 概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
  • 组件
🔥编辑器 (opens new window)
  • 可视化编辑器 (opens new window)
  • RuleGo-Server (opens new window)
  • ❓问答

    • FAQ
💖支持
👥加入社区
  • Github (opens new window)
  • Gitee (opens new window)
  • GitCode (opens new window)
  • 更新日志 (opens new window)
  • English
  • 简体中文

广告采用随机轮播方式显示 ❤️成为赞助商
  • Endpoint概述
  • 快速入门
  • 路由
  • DSL
  • API
  • Options
    • Endpoint options
  • 组件

目录

Options

# Endpoint options v0.21.0+

// RouterOption is a function type for setting options on routing components.
type RouterOption func(OptionsSetter) error

// RouterOptions holds the default router options.
var RouterOptions = routerOptions{}

type routerOptions struct {
}

// WithRuleGoFunc sets a function to dynamically retrieve the rule engine pool.
func (r routerOptions) WithRuleGoFunc(f func(exchange *Exchange) types.RuleEnginePool) RouterOption {
	return func(re OptionsSetter) error {
		re.SetRuleEnginePoolFunc(f)
		return nil
	}
}

// WithRuleGo sets the rule engine pool, defaulting to `rulego.DefaultPool`.
func (r routerOptions) WithRuleGo(ruleGo types.RuleEnginePool) RouterOption {
	return func(re OptionsSetter) error {
		re.SetRuleEnginePool(ruleGo)
		return nil
	}
}

// WithRuleConfig sets the rule engine configuration.
func (r routerOptions) WithRuleConfig(config types.Config) RouterOption {
	return func(re OptionsSetter) error {
		re.SetConfig(config)
		return nil
	}
}

// WithContextFunc sets the context function for the routing operation.
func (r routerOptions) WithContextFunc(f func(ctx context.Context, exchange *Exchange) context.Context) RouterOption {
	return func(re OptionsSetter) error {
		re.SetContextFunc(f)
		return nil
	}
}

func (r routerOptions) WithDefinition(def *types.RouterDsl) RouterOption {
	return func(re OptionsSetter) error {
		re.SetDefinition(def)
		return nil
	}
}

// DynamicEndpointOption is a function type for setting options on dynamic endpoints.
type DynamicEndpointOption func(DynamicEndpoint) error

// DynamicEndpointOptions holds the default dynamic endpoint options.
var DynamicEndpointOptions = dynamicEndpointOptions{}

type dynamicEndpointOptions struct {
}

// WithId sets the ID for the dynamic endpoint.
func (d dynamicEndpointOptions) WithId(id string) DynamicEndpointOption {
	return func(re DynamicEndpoint) error {
		re.SetId(id)
		return nil
	}
}

// WithConfig sets the configuration for the dynamic endpoint.
func (d dynamicEndpointOptions) WithConfig(config types.Config) DynamicEndpointOption {
	return func(re DynamicEndpoint) error {
		re.SetConfig(config)
		return nil
	}
}

// WithRouterOpts sets the routerOptions for the dynamic endpoint.
func (d dynamicEndpointOptions) WithRouterOpts(opts ...RouterOption) DynamicEndpointOption {
	return func(re DynamicEndpoint) error {
		re.SetRouterOptions(opts...)
		return nil
	}
}

// WithOnEvent sets the event handler for the dynamic endpoint.
func (d dynamicEndpointOptions) WithOnEvent(onEvent OnEvent) DynamicEndpointOption {
	return func(re DynamicEndpoint) error {
		re.SetOnEvent(onEvent)
		return nil
	}
}

// WithRestart sets restart sign for the dynamic endpoint.
func (d dynamicEndpointOptions) WithRestart(restart bool) DynamicEndpointOption {
	return func(re DynamicEndpoint) error {
		re.SetRestart(restart)
		return nil
	}
}

// WithInterceptors sets the interceptors for the dynamic endpoint.
func (d dynamicEndpointOptions) WithInterceptors(interceptors ...Process) DynamicEndpointOption {
	return func(re DynamicEndpoint) error {
		re.SetInterceptors(interceptors...)
		return nil
	}
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
在 GitHub 上编辑此页 (opens new window)
上次更新: 2025/03/31, 01:52:11
API
Rest Endpoint

← API Rest Endpoint→

Theme by Vdoing | Copyright © 2023-2025 RuleGo Team | Apache 2.0 License

  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式