本文整理汇总了Golang中github.com/revel/revel.Params类的典型用法代码示例。如果您正苦于以下问题:Golang Params类的具体用法?Golang Params怎么用?Golang Params使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Params类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: PerformActions
func PerformActions(params *revel.Params, serverInterface models.ServerInterface) {
var action = strings.ToLower(params.Get("action"))
switch action {
case "start":
serverInterface.Start()
case "stop":
serverInterface.Stop()
case "run":
serverInterface.Run()
}
}
开发者ID:digideskio,项目名称:watchdog_ui,代码行数:12,代码来源:api_servers.go
示例2: bindCard
func bindCard(params *revel.Params, name string, typ reflect.Type) reflect.Value {
var card models.Card
if name == "card" && typ == reflect.TypeOf(card) {
params.Bind(&card.CardBody, "CardBody")
params.Bind(&card.CardBlanks, "CardBlanks")
params.Bind(&card.CardType, "CardType")
return reflect.ValueOf(card)
}
return reflect.ValueOf(nil)
}
开发者ID:caneroj1,项目名称:cardsAPI,代码行数:11,代码来源:binders.go
示例3: AuthenticateBase
func (a *LinkedinAuthProvider) AuthenticateBase(parent *AuthProvider, params *revel.Params) (resp AuthResponse, err error) {
// assumption: validation has previously been done revel.OnAppStart() and then in in Authenticate()
errorCode := params.Get("error")
if errorCode != "" {
resp = AuthResponse{Type: AuthResponseError, Response: params.Get("error_description")}
return resp, err
}
code := params.Get("code")
if code == "" {
// we have no token, so begin authorization
theUrl, _ := url.ParseRequestURI(parent.AuthConfig.AuthorizeUrl)
// create a Map of all necessary params to pass to authenticator
valueMap, _ := parent.MapAuthInitatorValues(parent)
valueMap.Add("state", "blahblahblah")
theUrl.RawQuery = valueMap.Encode()
resp = AuthResponse{Type: AuthResponseRedirect, Response: theUrl.String()}
return resp, err
} else {
// we have a code, so it's exchange time!
theUrl, _ := url.ParseRequestURI(parent.AuthConfig.AccessTokenUrl)
// create a map of all necessary params to pass to authenticator
valueMap, _ := parent.MapExchangeValues(parent)
valueMap.Add("code", code)
valueMap.Add("state", "blahblahblah")
// push the whole valueMap into the URL instance
theUrl.RawQuery = valueMap.Encode()
// do the POST, then post
theJson, err := postRequestForJson(theUrl.Scheme+"://"+theUrl.Host+theUrl.Path, valueMap.Encode())
if err == nil {
resp = AuthResponse{Type: AuthResponseString, Response: theJson}
return resp, err
} else {
resp = AuthResponse{Type: AuthResponseError, Response: err.Error()}
return resp, err
}
}
}
开发者ID:golightspeed,项目名称:bouncer,代码行数:43,代码来源:linkedin.go
示例4: AuthenticateBase
func (a *TwitterAuthProvider) AuthenticateBase(parent *AuthProvider, params *revel.Params) (resp AuthResponse, err error) {
// assumption: validation has previously been done revel.OnAppStart() and then in in Authenticate()
errorCode := params.Get("error_code")
if errorCode != "" {
resp = AuthResponse{Type: AuthResponseError, Response: params.Get("error_message")}
return resp, err
}
token := params.Get("oauth_token")
verifier := params.Get("oauth_verifier")
if token == "" && verifier == "" { // Step 1: obtain a request token and redirect user
theUrl, _ := url.ParseRequestURI(parent.AuthConfig.RequestTokenUrl)
// create a Map of all necessary params to pass to authenticator
valueMap, _ := parent.MapAuthInitatorValues(parent)
theUrl.RawQuery = valueMap.Encode()
// do the POST to get the oauth_token
theJson, err := postRequestForJson(theUrl.Scheme+"://"+theUrl.Host+theUrl.Path, valueMap.Encode())
if err != nil {
resp = AuthResponse{Type: AuthResponseError, Response: err.Error()}
return resp, err
}
// extract oauth_token out of theJson (which is not JSON, but rather a querystring)
vals, err := url.ParseQuery(theJson)
if err != nil {
resp = AuthResponse{Type: AuthResponseError, Response: err.Error()}
return resp, err
}
token := vals.Get("oauth_token")
if token == "" {
resp = AuthResponse{Type: AuthResponseError, Response: "No oauth token found in token request to Twitter."}
return resp, err
}
// redirect user to authenticate
redirectUrl, _ := url.ParseRequestURI(parent.AuthConfig.AuthorizeUrl)
v := url.Values{}
v.Set("oauth_token", token)
redirectUrl.RawQuery = v.Encode()
resp = AuthResponse{Type: AuthResponseRedirect, Response: redirectUrl.String()}
return resp, err
} else {
// we have a token and verifier, so it's exchange time!
theUrl, _ := url.ParseRequestURI(parent.AuthConfig.AccessTokenUrl)
// create a map of all necessary params to pass to authenticator
//valueMap, _ := parent.MapExchangeValues(parent)
valueMap := url.Values{}
valueMap.Add("oauth_token", token)
valueMap.Add("oauth_verifier", verifier)
// push the whole valueMap into the URL instance
theUrl.RawQuery = valueMap.Encode()
// do the POST, then post
theJson, err := postRequestForJson(theUrl.Scheme+"://"+theUrl.Host+theUrl.Path, valueMap.Encode())
if err == nil {
resp = AuthResponse{Type: AuthResponseString, Response: theJson}
return resp, err
} else {
resp = AuthResponse{Type: AuthResponseError, Response: err.Error()}
return resp, err
}
}
}
开发者ID:golightspeed,项目名称:bouncer,代码行数:69,代码来源:twitter.go
示例5: NewServerFromParams
func NewServerFromParams(Params *revel.Params) (server *Server) {
server = &Server{
Label: Params.Get("label"),
Username: Params.Get("username"),
Host: Params.Get("host"),
Port: Params.Get("port"),
}
queryInterval, err := strconv.Atoi(Params.Get("query_interval"))
if err != nil {
server.SetQueryInterval(60)
} else {
server.SetQueryInterval(queryInterval)
}
server.ParsePrivateKey(Params.Get("private_key"))
server.SetPassword(Params.Get("password"))
var cmds [][]string
Params.Bind(&cmds, "commands")
server.Commands = make(map[string]string)
for _, cmd := range cmds {
if len(cmd) == 2 && cmd[0] != "" && cmd[1] != "" {
server.Commands[cmd[0]] = cmd[1]
}
}
return
}
开发者ID:digideskio,项目名称:watchdog_ui,代码行数:28,代码来源:server.go
注:本文中的github.com/revel/revel.Params类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论