Documentation ¶
Overview ¶
Package gweb Support HTTP Server, restful api handler, with timeout setting Support RPC Server, but this only called by golang rpc client, not good enough
Index ¶
- Variables
- func AddRoute(r *Route)
- func ConnectMongo(moc *MongoConfig)
- func ConnectMysql(myc *MysqlConfig)
- func ConnectRedis(rec *RedisConfig)
- func GetMongoClone() *mgo.Session
- func GetMongoDB() *mgo.Session
- func GetMysqlDB() *gorm.DB
- func GetRedisDB() *redis.Client
- func GetRpcServer() *rpc.Server
- func NewMongoColl(dbName, collName string) *mgo.Collection
- func NewMongoDB(dbName string) *mgo.Database
- func OpenSafeHanlder(isOpen bool)
- func SetDoneHook(fn http.HandlerFunc)
- func SetEntryHook(fn HandleEntryFunc)
- func SetFileHanlder(pattern, path string)
- func StartHttpServer(servConfig *ServerConfig)
- func StartRpcServer(rpcConfig *RpcServerConfig)
- type ApiHandler
- type HandleEntryFunc
- type JsonErr
- type MongoConfig
- type MysqlConfig
- type RedisConfig
- type Route
- type RpcServerConfig
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ApiHdl = &ApiHandler{} // ApiHandler Routes = map[string][]*Route{} // Routes )
Functions ¶
func GetRpcServer ¶
GetRpcServer get rcp.server instance to register
func NewMongoColl ¶
func NewMongoColl(dbName, collName string) *mgo.Collection
Create Mgo Collection
func OpenSafeHanlder ¶
func OpenSafeHanlder(isOpen bool)
Open or Close safe handler to recover from panic err
func SetEntryHook ¶
func SetEntryHook(fn HandleEntryFunc)
SetEntryHook to set the `http.HanlderFunc` but to remember, you'd not want to read the body directly, if you must, copy from the request, and op the copy
func SetFileHanlder ¶
func SetFileHanlder(pattern, path string)
func StartHttpServer ¶
func StartHttpServer(servConfig *ServerConfig)
StartHttpServer over HTTP as for api server
func StartRpcServer ¶
func StartRpcServer(rpcConfig *RpcServerConfig)
StartRpcSerevr running a server to deal with rpc request default set jsonrpc
Types ¶
type ApiHandler ¶
type ApiHandler struct { NotFound http.Handler MethodNotAllowed http.Handler ServeHttpEntryHook HandleEntryFunc // entryHookFunc ServeHttpDoneHook http.HandlerFunc // doneHookFunc }
func (*ApiHandler) ServeHTTP ¶
func (a *ApiHandler) ServeHTTP(w http.ResponseWriter, req *http.Request)
type HandleEntryFunc ¶
type HandleEntryFunc func(w http.ResponseWriter, req *http.Request) *CodeInfo
type JsonErr ¶
type JsonErr struct { CodeInfo Errs interface{} `json:"errs"` }
JsonErr Includes `Errs` field which contains interface{} value
type MongoConfig ¶
type MysqlConfig ¶
type RedisConfig ¶
type RpcServerConfig ¶
type ServerConfig ¶
Directories ¶
Path | Synopsis |
---|---|
Package middleware include param, reqlog, response, safe related functional modules
|
Package middleware include param, reqlog, response, safe related functional modules |
Package utils string.go includes utils functions related string
|
Package utils string.go includes utils functions related string |
Click to show internal directories.
Click to hide internal directories.