Documentation ¶
Index ¶
- func NewClientConfig(rc *ClientConfig)
- func NewMSession(dsn string) (*mgo.Session, error)
- func Routes() http.Handler
- func WriteResponseToUser(w http.ResponseWriter, code int, resp interface{}) error
- type ClientConfig
- func (cc *ClientConfig) CreateBlogs(bp *models.BlogItemPayload) (*pb.CreateBlogResponse, error)
- func (cc *ClientConfig) DeleteBlogs(id string) (*pb.DeleteBlogResponse, error)
- func (cc *ClientConfig) GetAllBlogs(num uint32) ([]*pb.ListBlogResponse, error)
- func (cc *ClientConfig) GetAllBlogsHandler(w http.ResponseWriter, r *http.Request)
- func (cc *ClientConfig) GetBlogHandler(w http.ResponseWriter, r *http.Request)
- func (cc *ClientConfig) InsertBlogHandler(w http.ResponseWriter, r *http.Request)
- func (cc *ClientConfig) ReadBlogs(id string) (*pb.ReadBlogResponse, error)
- func (cc *ClientConfig) StatusHandler(w http.ResponseWriter, r *http.Request)
- func (cc *ClientConfig) UpdateBlogs(bp *models.BlogItemPayload) (*pb.UpdateBlogResponse, error)
- type MongoTools
- type RestConf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientConfig ¶
func NewClientConfig(rc *ClientConfig)
NewClientConfig use for creating the configuration structure for whole RPC Client
func NewMSession ¶
NewMSession use for creating mongodb session for client-side
func WriteResponseToUser ¶
func WriteResponseToUser(w http.ResponseWriter, code int, resp interface{}) error
WriteResponseToUser a helper function for writing our json response to user
Types ¶
type ClientConfig ¶
type ClientConfig struct { ClientConn *grpc.ClientConn BlogClient pb.BlogSystemClient RestConfig *RestConf }
ClientConfig useful for holding the client configuration objects
func (*ClientConfig) CreateBlogs ¶
func (cc *ClientConfig) CreateBlogs(bp *models.BlogItemPayload) (*pb.CreateBlogResponse, error)
CreateBlogs use for creating blog in out gRPC Server
func (*ClientConfig) DeleteBlogs ¶
func (cc *ClientConfig) DeleteBlogs(id string) (*pb.DeleteBlogResponse, error)
DeleteBlogs use for deleting blogs by getting its own ID
func (*ClientConfig) GetAllBlogs ¶
func (cc *ClientConfig) GetAllBlogs(num uint32) ([]*pb.ListBlogResponse, error)
GetAllBlogs use for getting all blogs from server
func (*ClientConfig) GetAllBlogsHandler ¶
func (cc *ClientConfig) GetAllBlogsHandler(w http.ResponseWriter, r *http.Request)
GetAllBlogsHandler use for getting all blogs from gRPC
func (*ClientConfig) GetBlogHandler ¶
func (cc *ClientConfig) GetBlogHandler(w http.ResponseWriter, r *http.Request)
GetBlogHandler a rest api handler for get a blog by its own ID
func (*ClientConfig) InsertBlogHandler ¶
func (cc *ClientConfig) InsertBlogHandler(w http.ResponseWriter, r *http.Request)
InsertBlogHandler a rest api handler for inserting a blog
func (*ClientConfig) ReadBlogs ¶
func (cc *ClientConfig) ReadBlogs(id string) (*pb.ReadBlogResponse, error)
ReadBlogs use for reading blogs by their own IDs
func (*ClientConfig) StatusHandler ¶
func (cc *ClientConfig) StatusHandler(w http.ResponseWriter, r *http.Request)
StatusHandler just use for showing the status of our API
func (*ClientConfig) UpdateBlogs ¶
func (cc *ClientConfig) UpdateBlogs(bp *models.BlogItemPayload) (*pb.UpdateBlogResponse, error)
UpdateBlogs use for updating blogs by getting blog payload
type MongoTools ¶
type MongoTools struct { MSession *mgo.Session Mdb *mgo.Database MCollection map[string]*mgo.Collection }
func (*MongoTools) NewMCollection ¶
func (rcf *MongoTools) NewMCollection(cname string)
NewMCollection use for adding or creating a collection into the db
func (*MongoTools) NewMDatabase ¶
func (rcf *MongoTools) NewMDatabase(dbname string)
NewMDatabase use for creating or adding a database into the db
type RestConf ¶
type RestConf struct {
Mongo *MongoTools
}
RestConf holding our rest api configurations