Files
gf/g/net/ghttp/ghttp_request_params.go

29 lines
767 B
Go

// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.
package ghttp
import "github.com/gogf/gf/g/container/gvar"
// 设置请求流程共享变量
func (r *Request) SetParam(key string, value interface{}) {
if r.params == nil {
r.params = make(map[string]interface{})
}
r.params[key] = value
}
// 获取请求流程共享变量
func (r *Request) GetParam(key string) gvar.VarRead {
if r.params != nil {
if v, ok := r.params[key]; ok {
return gvar.New(v, true)
}
}
return gvar.New(nil, true)
}