make new model for stringSlices allowOrigin helper
This commit is contained in:
16
args/args.go
16
args/args.go
@@ -2,7 +2,6 @@ package args
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"strings"
|
||||
|
||||
"github.com/tecamino/tecamino-dbm/cert"
|
||||
"github.com/tecamino/tecamino-dbm/models"
|
||||
@@ -19,21 +18,10 @@ type Args struct {
|
||||
Debug bool
|
||||
}
|
||||
|
||||
type StringSlice []string
|
||||
|
||||
func (s *StringSlice) String() string {
|
||||
return strings.Join(*s, ",")
|
||||
}
|
||||
|
||||
func (s *StringSlice) Set(value string) error {
|
||||
*s = append(*s, value)
|
||||
return nil
|
||||
}
|
||||
|
||||
// initialte cli arguments
|
||||
func Init() *Args {
|
||||
|
||||
var allowOrigins StringSlice
|
||||
var allowOrigins models.StringSlice
|
||||
|
||||
flag.Var(&allowOrigins, "allowOrigin", "Allowed origin (can repeat this flag)")
|
||||
|
||||
@@ -67,7 +55,7 @@ func Init() *Args {
|
||||
}
|
||||
|
||||
if len(allowOrigins) == 0 {
|
||||
allowOrigins = StringSlice{"http://localhost:9500"}
|
||||
allowOrigins = models.StringSlice{"http://localhost:9500"}
|
||||
}
|
||||
|
||||
a.AllowOrigins = allowOrigins
|
||||
|
Reference in New Issue
Block a user