github.com/zhongdalu/gf@v1.0.0/g/g_object.go (about)

     1  // Copyright 2018 gf Author(https://github.com/zhongdalu/gf). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/zhongdalu/gf.
     6  
     7  package g
     8  
     9  import (
    10  	"github.com/zhongdalu/gf/g/database/gdb"
    11  	"github.com/zhongdalu/gf/g/database/gredis"
    12  	"github.com/zhongdalu/gf/g/frame/gins"
    13  	"github.com/zhongdalu/gf/g/net/ghttp"
    14  	"github.com/zhongdalu/gf/g/net/gtcp"
    15  	"github.com/zhongdalu/gf/g/net/gudp"
    16  	"github.com/zhongdalu/gf/g/os/gcfg"
    17  	"github.com/zhongdalu/gf/g/os/gview"
    18  )
    19  
    20  // Server returns an instance of http server with specified name.
    21  func Server(name ...interface{}) *ghttp.Server {
    22  	return ghttp.GetServer(name...)
    23  }
    24  
    25  // TCPServer returns an instance of tcp server with specified name.
    26  func TCPServer(name ...interface{}) *gtcp.Server {
    27  	return gtcp.GetServer(name...)
    28  }
    29  
    30  // UDPServer returns an instance of udp server with specified name.
    31  func UDPServer(name ...interface{}) *gudp.Server {
    32  	return gudp.GetServer(name...)
    33  }
    34  
    35  // View returns an instance of template engine object with specified name.
    36  func View(name ...string) *gview.View {
    37  	return gins.View(name...)
    38  }
    39  
    40  // Config returns an instance of config object with specified name.
    41  func Config(name ...string) *gcfg.Config {
    42  	return gins.Config(name...)
    43  }
    44  
    45  // Database returns an instance of database ORM object with specified configuration group name.
    46  func Database(name ...string) gdb.DB {
    47  	return gins.Database(name...)
    48  }
    49  
    50  // DB is alias of Database.
    51  // See Database.
    52  func DB(name ...string) gdb.DB {
    53  	return gins.Database(name...)
    54  }
    55  
    56  // Redis returns an instance of redis client with specified configuration group name.
    57  func Redis(name ...string) *gredis.Redis {
    58  	return gins.Redis(name...)
    59  }