2021-03-24 14:26:46 +01:00
|
|
|
package openbgpd
|
|
|
|
|
2021-04-26 22:01:26 +02:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2021-07-05 16:21:46 +02:00
|
|
|
"time"
|
2021-09-15 17:08:53 +02:00
|
|
|
|
|
|
|
"github.com/alice-lg/alice-lg/pkg/api"
|
2021-04-26 22:01:26 +02:00
|
|
|
)
|
|
|
|
|
2021-03-24 14:26:46 +01:00
|
|
|
// Config is a OpenBGPD source config
|
|
|
|
type Config struct {
|
|
|
|
ID string
|
|
|
|
Name string
|
|
|
|
|
2021-09-15 17:28:01 +02:00
|
|
|
CacheTTL time.Duration
|
|
|
|
RoutesCacheSize int
|
2021-07-05 16:21:46 +02:00
|
|
|
|
2021-03-24 14:26:46 +01:00
|
|
|
API string `ini:"api"`
|
2021-09-15 17:08:53 +02:00
|
|
|
|
|
|
|
RejectCommunities api.Communities
|
2021-03-24 14:26:46 +01:00
|
|
|
}
|
2021-04-26 22:01:26 +02:00
|
|
|
|
|
|
|
// APIURL creates an url from the config
|
|
|
|
func (cfg *Config) APIURL(path string, params ...interface{}) string {
|
2021-10-15 17:39:09 +02:00
|
|
|
u := strings.TrimSuffix(cfg.API, "/")
|
2021-04-26 22:01:26 +02:00
|
|
|
u += fmt.Sprintf(path, params...)
|
|
|
|
return u
|
|
|
|
}
|