Add fox-ess-h3-smart inverters (#21176)
This commit is contained in:
parent
34cf433b1b
commit
8252d37bd5
69 changed files with 24572 additions and 211 deletions
7
plugin/auth/api 2.go
Normal file
7
plugin/auth/api 2.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package auth
|
||||
|
||||
import "net/http"
|
||||
|
||||
type Authorizer interface {
|
||||
Transport(base http.RoundTripper) (http.RoundTripper, error)
|
||||
}
|
||||
26
plugin/auth/config 2.go
Normal file
26
plugin/auth/config 2.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
reg "github.com/evcc-io/evcc/util/registry"
|
||||
)
|
||||
|
||||
var registry = reg.New[Authorizer]("auth")
|
||||
|
||||
// NewFromConfig creates auth from configuration
|
||||
func NewFromConfig(ctx context.Context, typ string, other map[string]any) (Authorizer, error) {
|
||||
factory, err := registry.Get(strings.ToLower(typ))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
v, err := factory(ctx, other)
|
||||
if err != nil {
|
||||
err = fmt.Errorf("cannot create auth type '%s': %w", typ, err)
|
||||
}
|
||||
|
||||
return v, err
|
||||
}
|
||||
27
plugin/auth/nop 2.go
Normal file
27
plugin/auth/nop 2.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/evcc-io/evcc/util"
|
||||
)
|
||||
|
||||
type nop struct{}
|
||||
|
||||
func init() {
|
||||
registry.AddCtx("nop", NewNopFromConfig)
|
||||
}
|
||||
|
||||
func NewNopFromConfig(ctx context.Context, other map[string]any) (Authorizer, error) {
|
||||
var cc struct{}
|
||||
if err := util.DecodeOther(other, &cc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return new(nop), nil
|
||||
}
|
||||
|
||||
func (p *nop) Transport(base http.RoundTripper) (http.RoundTripper, error) {
|
||||
return base, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue