mirror of
https://gitee.com/johng/gf
synced 2026-07-05 13:22:16 +08:00
up
This commit is contained in:
@ -62,6 +62,9 @@ func (r *Response) ParseTplContent(content string, params map[string]interface{}
|
||||
|
||||
// 内置变量
|
||||
func (r *Response) buildInVars(params map[string]interface{}) map[string]interface{} {
|
||||
if params == nil {
|
||||
params = make(map[string]interface{})
|
||||
}
|
||||
params["Config"] = gins.Config().GetMap("")
|
||||
params["Cookie"] = r.request.Cookie.Map()
|
||||
params["Session"] = r.request.Session.Data()
|
||||
@ -70,6 +73,9 @@ func (r *Response) buildInVars(params map[string]interface{}) map[string]interfa
|
||||
|
||||
// 内置函数
|
||||
func (r *Response) buildInfuncs(funcmap map[string]interface{}) map[string]interface{} {
|
||||
if funcmap == nil {
|
||||
funcmap = make(map[string]interface{})
|
||||
}
|
||||
funcmap["get"] = r.funcGet
|
||||
funcmap["post"] = r.funcPost
|
||||
funcmap["request"] = r.funcRequest
|
||||
|
||||
23
geg/net/ghttp/server/template/tpl.go
Normal file
23
geg/net/ghttp/server/template/tpl.go
Normal file
@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"gitee.com/johng/gf/g"
|
||||
"gitee.com/johng/gf/g/net/ghttp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
s := g.Server()
|
||||
s.BindHandler("/", func(r *ghttp.Request){
|
||||
content :=
|
||||
`
|
||||
{{if (get "name")}}
|
||||
{{get "name"}}
|
||||
{{else}}
|
||||
NoName
|
||||
{{end}}
|
||||
`
|
||||
r.Response.WriteTplContent(content, nil)
|
||||
})
|
||||
s.SetPort(8199)
|
||||
s.Run()
|
||||
}
|
||||
31
geg/os/gcfg/config.toml
Normal file
31
geg/os/gcfg/config.toml
Normal file
@ -0,0 +1,31 @@
|
||||
# redis配置
|
||||
[[redis-cache]]
|
||||
db = 0
|
||||
host = "192.168.0.100"
|
||||
port = 6379
|
||||
|
||||
[[redis-cache]]
|
||||
db = 1
|
||||
host = "192.168.0.100"
|
||||
port = 6379
|
||||
|
||||
[[redis-disk]]
|
||||
db = 0
|
||||
host = "192.168.0.100"
|
||||
port = 6380
|
||||
|
||||
[[redis-disk]]
|
||||
db = 1
|
||||
host = "192.168.0.100"
|
||||
port = 6380
|
||||
|
||||
# memcache配置
|
||||
[[memcache]]
|
||||
host = "192.168.0.101"
|
||||
port = 11211
|
||||
expire = 60
|
||||
|
||||
[[memcache]]
|
||||
host = "192.168.0.102"
|
||||
port = 11211
|
||||
expire = 60
|
||||
@ -1,26 +0,0 @@
|
||||
redis:
|
||||
cache:
|
||||
- host: 192.168.0.100
|
||||
port: 6379
|
||||
db: 0
|
||||
- host: 192.168.0.100
|
||||
port: 6379
|
||||
db: 1
|
||||
disk:
|
||||
- host: 192.168.0.100
|
||||
port: 6380
|
||||
db: 0
|
||||
- host: 192.168.0.100
|
||||
port: 6380
|
||||
db: 1
|
||||
|
||||
memcache:
|
||||
- host: 192.168.0.101
|
||||
port: 11211
|
||||
expire: 60
|
||||
- host: 192.168.0.102
|
||||
port: 11211
|
||||
expire: 60
|
||||
|
||||
viewpath : /home/www/templates/
|
||||
serverpath : /home/www/server/
|
||||
@ -7,9 +7,9 @@ import (
|
||||
|
||||
func main() {
|
||||
c := gcfg.New("/home/john/Workspace/Go/GOPATH/src/gitee.com/johng/gf/geg/os/gcfg")
|
||||
redisConfig := c.GetArray("redis-cache", "redis.yml")
|
||||
memcacheConfig := c.GetArray("", "memcache.yml")
|
||||
redisConfig := c.GetArray("redis-cache", "redis.toml")
|
||||
memConfig := c.GetArray("", "memcache.yml")
|
||||
fmt.Println(redisConfig)
|
||||
fmt.Println(memcacheConfig)
|
||||
fmt.Println(memConfig)
|
||||
}
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
# memcache配置
|
||||
- host: 192.168.0.101
|
||||
port: 11211
|
||||
expire: 60
|
||||
|
||||
20
geg/os/gcfg/redis.toml
Normal file
20
geg/os/gcfg/redis.toml
Normal file
@ -0,0 +1,20 @@
|
||||
# redis配置
|
||||
[[redis-cache]]
|
||||
db = 0
|
||||
host = "192.168.0.100"
|
||||
port = 6379
|
||||
|
||||
[[redis-cache]]
|
||||
db = 1
|
||||
host = "192.168.0.100"
|
||||
port = 6379
|
||||
|
||||
[[redis-disk]]
|
||||
db = 0
|
||||
host = "192.168.0.100"
|
||||
port = 6380
|
||||
|
||||
[[redis-disk]]
|
||||
db = 1
|
||||
host = "192.168.0.100"
|
||||
port = 6380
|
||||
@ -1,14 +0,0 @@
|
||||
redis-cache:
|
||||
- host: 192.168.0.100
|
||||
port: 6379
|
||||
db: 0
|
||||
- host: 192.168.0.100
|
||||
port: 6379
|
||||
db: 1
|
||||
redis-disk:
|
||||
- host: 192.168.0.100
|
||||
port: 6380
|
||||
db: 0
|
||||
- host: 192.168.0.100
|
||||
port: 6380
|
||||
db: 1
|
||||
Reference in New Issue
Block a user