Add aggregate configuration support and update documentation
- Introduced AggregateConfig to manage aggregation settings in the gateway configuration. - Added validation for reserved alias 'agg' and included tests for aggregate alias handling. - Updated config.example.yaml to demonstrate aggregate configuration options. - Enhanced README.md to include information about the new aggregation endpoint and its usage. - Modified gateway.go to integrate the new aggregate handler for processing aggregation requests.
This commit is contained in:
@@ -62,3 +62,39 @@ func TestValidateDuplicateAlias(t *testing.T) {
|
||||
t.Fatal("expected error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateReservedAggAlias(t *testing.T) {
|
||||
c := &Config{
|
||||
Servers: []Server{
|
||||
{Alias: "agg", BaseURL: "http://x:1"},
|
||||
},
|
||||
}
|
||||
if err := c.Validate(); err == nil {
|
||||
t.Fatal("expected error for reserved alias agg")
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidateAggregateIncludeAliases(t *testing.T) {
|
||||
c := &Config{
|
||||
Servers: []Server{
|
||||
{Alias: "a", BaseURL: "http://x:1"},
|
||||
},
|
||||
Aggregate: &AggregateConfig{
|
||||
IncludeAliases: []string{"a"},
|
||||
},
|
||||
}
|
||||
if err := c.Validate(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
c2 := &Config{
|
||||
Servers: []Server{
|
||||
{Alias: "a", BaseURL: "http://x:1"},
|
||||
},
|
||||
Aggregate: &AggregateConfig{
|
||||
IncludeAliases: []string{"nope"},
|
||||
},
|
||||
}
|
||||
if err := c2.Validate(); err == nil {
|
||||
t.Fatal("expected error for unknown include alias")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user