remove the old config library files from the API
All checks were successful
Build the docker image for the API / build (push) Successful in 2m36s
All checks were successful
Build the docker image for the API / build (push) Successful in 2m36s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
parent
05185cb82a
commit
dc43bdb3af
@ -1,49 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
OPTION_TYPE_STR = 0
|
||||
OPTION_TYPE_BOOL = 1
|
||||
OPTION_TYPE_URL = 2
|
||||
)
|
||||
|
||||
type Option struct {
|
||||
Name string
|
||||
Value string
|
||||
Required bool
|
||||
Type uint8
|
||||
TypeValue struct {
|
||||
URL *url.URL
|
||||
Str string
|
||||
Bool bool
|
||||
}
|
||||
}
|
||||
|
||||
func (o *Option) Env() string {
|
||||
return strings.ToUpper(fmt.Sprintf("WEBSITE_%s", o.Name))
|
||||
}
|
||||
|
||||
func (o *Option) Load() (err error) {
|
||||
err = nil
|
||||
|
||||
switch o.Type {
|
||||
case OPTION_TYPE_STR:
|
||||
o.TypeValue.Str = o.Value
|
||||
|
||||
case OPTION_TYPE_BOOL:
|
||||
o.TypeValue.Bool = "1" == o.Value || "true" == strings.ToLower(o.Value)
|
||||
|
||||
case OPTION_TYPE_URL:
|
||||
o.TypeValue.URL, err = url.Parse(o.Value)
|
||||
|
||||
default:
|
||||
return fmt.Errorf("invalid option type")
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user