本文整理匯總了Golang中github.com/joewalnes/websocketd/libwebsocketd.Config.AllowOrigins方法的典型用法代碼示例。如果您正苦於以下問題:Golang Config.AllowOrigins方法的具體用法?Golang Config.AllowOrigins怎麽用?Golang Config.AllowOrigins使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/joewalnes/websocketd/libwebsocketd.Config
的用法示例。
在下文中一共展示了Config.AllowOrigins方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: parseCommandLine
//.........這裏部分代碼省略.........
// Reading SSL options
if config.Ssl {
if *sslCert == "" || *sslKey == "" {
fmt.Fprintf(os.Stderr, "Please specify both --sslcert and --sslkey when requesting --ssl.\n")
os.Exit(1)
}
} else {
if *sslCert != "" || *sslKey != "" {
fmt.Fprintf(os.Stderr, "You should not be using --ssl* flags when there is no --ssl option.\n")
os.Exit(1)
}
}
mainConfig.CertFile = *sslCert
mainConfig.KeyFile = *sslKey
// Building config.ParentEnv to avoid calling Environ all the time in the scripts
// (caller is responsible for wiping environment if desired)
config.ParentEnv = make([]string, 0)
newlineCleaner := strings.NewReplacer("\n", " ", "\r", " ")
for _, key := range strings.Split(*passEnvFlag, ",") {
if key != "HTTPS" {
if v := os.Getenv(key); v != "" {
// inevitably adding flavor of libwebsocketd appendEnv func.
// it's slightly nicer than in net/http/cgi implementation
if clean := strings.TrimSpace(newlineCleaner.Replace(v)); clean != "" {
config.ParentEnv = append(config.ParentEnv, fmt.Sprintf("%s=%s", key, clean))
}
}
}
}
if *allowOriginsFlag != "" {
config.AllowOrigins = strings.Split(*allowOriginsFlag, ",")
}
config.SameOrigin = *sameOriginFlag
args := flag.Args()
if len(args) < 1 && config.ScriptDir == "" && config.StaticDir == "" && config.CgiDir == "" {
fmt.Fprintf(os.Stderr, "Please specify COMMAND or provide --dir, --staticdir or --cgidir argument.\n")
ShortHelp()
os.Exit(1)
}
if len(args) > 0 {
if config.ScriptDir != "" {
fmt.Fprintf(os.Stderr, "Ambiguous. Provided COMMAND and --dir argument. Please only specify just one.\n")
ShortHelp()
os.Exit(1)
}
if path, err := exec.LookPath(args[0]); err == nil {
config.CommandName = path // This can be command in PATH that we are able to execute
config.CommandArgs = flag.Args()[1:]
config.UsingScriptDir = false
} else {
fmt.Fprintf(os.Stderr, "Unable to locate specified COMMAND '%s' in OS path.\n", args[0])
ShortHelp()
os.Exit(1)
}
}
if config.ScriptDir != "" {
scriptDir, err := filepath.Abs(config.ScriptDir)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not resolve absolute path to dir '%s'.\n", config.ScriptDir)
ShortHelp()