MCPcopy Create free account
hub / github.com/coder/aibridge / validateProviders

Function validateProviders

bridge.go:67–80  ·  view source on GitHub ↗

validateProviders checks that provider names are valid and unique.

(providers []provider.Provider)

Source from the content-addressed store, hash-verified

65
66// validateProviders checks that provider names are valid and unique.
67func validateProviders(providers []provider.Provider) error {
68 names := make(map[string]bool, len(providers))
69 for _, prov := range providers {
70 name := prov.Name()
71 if !validProviderName.MatchString(name) {
72 return xerrors.Errorf("invalid provider name %q: must contain only lowercase alphanumeric characters and hyphens", name)
73 }
74 if names[name] {
75 return xerrors.Errorf("duplicate provider name: %q", name)
76 }
77 names[name] = true
78 }
79 return nil
80}
81
82// NewRequestBridge creates a new *[RequestBridge] and registers the HTTP routes defined by the given providers.
83// Any routes which are requested but not registered will be reverse-proxied to the upstream service.

Callers 1

NewRequestBridgeFunction · 0.85

Calls 1

NameMethod · 0.65

Tested by

no test coverage detected