2019-02-02 16:18:25 +08:00
|
|
|
// Copyright 2018 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
2018-09-26 09:58:49 +08:00
|
|
|
//
|
|
|
|
// 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,
|
2019-02-02 16:18:25 +08:00
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
2018-09-26 09:58:49 +08:00
|
|
|
|
|
|
|
package g
|
|
|
|
|
|
|
|
import (
|
2019-02-02 16:18:25 +08:00
|
|
|
"github.com/gogf/gf/g/database/gdb"
|
|
|
|
"github.com/gogf/gf/g/database/gredis"
|
|
|
|
"github.com/gogf/gf/g/frame/gins"
|
|
|
|
"github.com/gogf/gf/g/net/ghttp"
|
|
|
|
"github.com/gogf/gf/g/net/gtcp"
|
|
|
|
"github.com/gogf/gf/g/net/gudp"
|
|
|
|
"github.com/gogf/gf/g/os/gview"
|
|
|
|
"github.com/gogf/gf/g/os/gcfg"
|
2018-09-26 09:58:49 +08:00
|
|
|
)
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// Server returns an instance of http server with specified name.
|
2018-09-26 09:58:49 +08:00
|
|
|
func Server(name...interface{}) *ghttp.Server {
|
|
|
|
return ghttp.GetServer(name...)
|
|
|
|
}
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// TCPServer returns an instance of tcp server with specified name.
|
2018-12-17 13:02:18 +08:00
|
|
|
func TCPServer(name...interface{}) *gtcp.Server {
|
2018-09-26 09:58:49 +08:00
|
|
|
return gtcp.GetServer(name...)
|
|
|
|
}
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// UDPServer returns an instance of udp server with specified name.
|
2018-12-17 13:02:18 +08:00
|
|
|
func UDPServer(name...interface{}) *gudp.Server {
|
2018-09-26 09:58:49 +08:00
|
|
|
return gudp.GetServer(name...)
|
|
|
|
}
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// View returns an instance of template engine object with specified name.
|
2018-10-15 22:39:56 +08:00
|
|
|
func View(name...string) *gview.View {
|
|
|
|
return gins.View(name...)
|
2018-09-26 09:58:49 +08:00
|
|
|
}
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// Config returns an instance of config object with specified name.
|
2018-10-13 20:43:21 +08:00
|
|
|
func Config(file...string) *gcfg.Config {
|
|
|
|
return gins.Config(file...)
|
2018-09-26 09:58:49 +08:00
|
|
|
}
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// Database returns an instance of database ORM object with specified configuration group name.
|
2018-12-15 15:50:39 +08:00
|
|
|
func Database(name...string) gdb.DB {
|
2018-10-13 20:29:27 +08:00
|
|
|
return gins.Database(name...)
|
|
|
|
}
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// Alias of Database. See Database.
|
2018-12-15 15:50:39 +08:00
|
|
|
func DB(name...string) gdb.DB {
|
2018-10-13 20:29:27 +08:00
|
|
|
return gins.Database(name...)
|
2018-09-26 09:58:49 +08:00
|
|
|
}
|
|
|
|
|
2019-04-04 22:52:56 +08:00
|
|
|
// Redis returns an instance of redis client with specified configuration group name.
|
2018-09-26 09:58:49 +08:00
|
|
|
func Redis(name...string) *gredis.Redis {
|
2018-10-13 21:13:18 +08:00
|
|
|
return gins.Redis(name...)
|
2018-09-26 09:58:49 +08:00
|
|
|
}
|