本文整理匯總了Golang中github.com/daohoangson/go-socialcounters/utils.Utils.ConfigGet方法的典型用法代碼示例。如果您正苦於以下問題:Golang Utils.ConfigGet方法的具體用法?Golang Utils.ConfigGet怎麽用?Golang Utils.ConfigGet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/daohoangson/go-socialcounters/utils.Utils
的用法示例。
在下文中一共展示了Utils.ConfigGet方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ConfigGet
func ConfigGet(u utils.Utils, w http.ResponseWriter, r *http.Request) {
specifiedSecret := parseSecret(r)
configSecret := os.Getenv("CONFIG_SECRET")
if configSecret == "" || specifiedSecret != configSecret {
w.WriteHeader(http.StatusForbidden)
writeJson(u, w, r, "{}")
u.Errorf("admin.ConfigGet: wrong secret %s", specifiedSecret)
return
}
keys := parseKeys(r)
values := make(map[string]string)
for _, key := range keys {
values[key] = u.ConfigGet(key)
}
valuesJson, err := json.Marshal(values)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
writeJson(u, w, r, "{}")
u.Errorf("admin.ConfigGet: json.Marshal(values) error %v", err)
return
}
writeJson(u, w, r, string(valuesJson))
}
示例2: getAdsAsJson
func getAdsAsJson(u utils.Utils) string {
json, err := json.Marshal(u.ConfigGet("ADS"))
if err != nil {
return "''"
}
return string(json)
}
示例3: prepareFbGraphUrl
func prepareFbGraphUrl(u utils.Utils, ids string) string {
scheme := "http"
accessToken := ""
if appId := u.ConfigGet("FACEBOOK_APP_ID"); appId != "" {
if appSecret := u.ConfigGet("FACEBOOK_APP_SECRET"); appSecret != "" {
scheme = "https"
accessToken = fmt.Sprintf("&access_token=%s|%s", appId, appSecret)
}
}
return fmt.Sprintf("%s://graph.facebook.com/?ids=%s&fields=share%s", scheme, neturl.QueryEscape(ids), accessToken)
}
示例4: getBlacklist
func getBlacklist(u utils.Utils, refresh bool) *regexp.Regexp {
if !blacklistPrepared || refresh {
if value := u.ConfigGet("BLACKLIST"); value != "" {
compiled, err := regexp.Compile(value)
if err != nil {
u.Errorf("web.getBlacklist error on %s: %v", value, err)
}
blacklist = compiled
}
blacklistPrepared = true
}
return blacklist
}
示例5: getWhitelist
func getWhitelist(u utils.Utils, refresh bool) *regexp.Regexp {
if !whitelistPrepared || refresh {
if value := u.ConfigGet("WHITELIST"); value != "" {
compiled, err := regexp.Compile(value)
if err != nil {
u.Errorf("web.getWhitelist error on %s: %v", value, err)
}
whitelist = compiled
}
whitelistPrepared = true
}
return whitelist
}