Skip to content

Commit c3a960e

Browse files
committed
feat: add GetProvider()
1 parent 3ae7b56 commit c3a960e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

goic.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func (g *Goic) NewProvider(name, uri string) *Provider {
104104
return p
105105
}
106106

107+
// AddProvider adds a Provider to Goic
107108
func (g *Goic) AddProvider(p *Provider) *Provider {
108109
if p, ok := g.providers[p.Name]; ok {
109110
g.logIf("goic provider %s: already set", p.Name)
@@ -118,6 +119,14 @@ func (g *Goic) AddProvider(p *Provider) *Provider {
118119
return p
119120
}
120121

122+
// GetProvider returns Provider by name or nil if not existent
123+
func (g *Goic) GetProvider(name string) *Provider {
124+
if p, ok := g.providers[name]; ok {
125+
return p
126+
}
127+
return nil
128+
}
129+
121130
// Supports checks if a given provider name is supported
122131
func (g *Goic) Supports(name string) bool {
123132
_, ok := g.providers[name]
@@ -536,6 +545,7 @@ func (g *Goic) errorHTML(res http.ResponseWriter, err error, h, label string) {
536545
_, _ = res.Write([]byte(err.Error() + h))
537546
}
538547

548+
// UnsetState unsets state from memory
539549
func (g *Goic) UnsetState(s string) {
540550
g.sLock.Lock()
541551
delete(g.states, s)

0 commit comments

Comments
 (0)