gf/frame/g/g_object.go

93 lines
2.5 KiB
Go
Raw Normal View History

// 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,
// You can obtain one at https://github.com/gogf/gf.
2018-09-26 09:58:49 +08:00
package g
import (
2019-07-29 21:01:19 +08:00
"github.com/gogf/gf/database/gdb"
"github.com/gogf/gf/database/gredis"
"github.com/gogf/gf/frame/gins"
2019-09-01 00:30:01 +08:00
"github.com/gogf/gf/i18n/gi18n"
2019-07-29 21:01:19 +08:00
"github.com/gogf/gf/net/ghttp"
"github.com/gogf/gf/net/gtcp"
"github.com/gogf/gf/net/gudp"
"github.com/gogf/gf/os/gcfg"
"github.com/gogf/gf/os/glog"
2019-08-19 21:02:44 +08:00
"github.com/gogf/gf/os/gres"
2019-07-29 21:01:19 +08:00
"github.com/gogf/gf/os/gview"
2018-09-26 09:58:49 +08:00
)
// Server returns an instance of http server with specified name.
2019-06-19 09:06:52 +08:00
func Server(name ...interface{}) *ghttp.Server {
return gins.Server(name...)
2018-09-26 09:58:49 +08:00
}
// TCPServer returns an instance of tcp server with specified name.
2019-06-19 09:06:52 +08:00
func TCPServer(name ...interface{}) *gtcp.Server {
return gtcp.GetServer(name...)
2018-09-26 09:58:49 +08:00
}
// UDPServer returns an instance of udp server with specified name.
2019-06-19 09:06:52 +08:00
func UDPServer(name ...interface{}) *gudp.Server {
return gudp.GetServer(name...)
2018-09-26 09:58:49 +08:00
}
// View returns an instance of template engine object with specified name.
2019-06-19 09:06:52 +08:00
func View(name ...string) *gview.View {
return gins.View(name...)
2018-09-26 09:58:49 +08:00
}
// Config returns an instance of config object with specified name.
2019-06-19 09:06:52 +08:00
func Config(name ...string) *gcfg.Config {
return gins.Config(name...)
2018-09-26 09:58:49 +08:00
}
// Cfg is alias of Config.
// See Config.
func Cfg(name ...string) *gcfg.Config {
return Config(name...)
}
2019-08-19 21:02:44 +08:00
// Resource returns an instance of Resource.
// The parameter <name> is the name for the instance.
func Resource(name ...string) *gres.Resource {
return gins.Resource(name...)
}
2019-09-01 00:30:01 +08:00
// I18n returns an instance of gi18n.Manager.
2019-08-31 18:04:12 +08:00
// The parameter <name> is the name for the instance.
2019-09-01 00:30:01 +08:00
func I18n(name ...string) *gi18n.Manager {
2019-08-31 18:04:12 +08:00
return gins.I18n(name...)
}
2019-08-19 21:02:44 +08:00
// Res is alias of Resource.
// See Resource.
func Res(name ...string) *gres.Resource {
return Resource(name...)
}
// Log returns an instance of glog.Logger.
// The parameter <name> is the name for the instance.
func Log(name ...string) *glog.Logger {
return gins.Log(name...)
}
// Database returns an instance of database ORM object with specified configuration group name.
2019-06-19 09:06:52 +08:00
func Database(name ...string) gdb.DB {
return gins.Database(name...)
}
2019-06-21 22:23:07 +08:00
// DB is alias of Database.
// See Database.
2019-06-19 09:06:52 +08:00
func DB(name ...string) gdb.DB {
return gins.Database(name...)
2018-09-26 09:58:49 +08:00
}
// Redis returns an instance of redis client with specified configuration group name.
2019-06-19 09:06:52 +08:00
func Redis(name ...string) *gredis.Redis {
return gins.Redis(name...)
}