api

package
v0.0.0-...-149877f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

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

func NewMSession(dsn string) (*mgo.Session, error)

NewMSession use for creating mongodb session for client-side

func Routes

func Routes() http.Handler

Routes make http handlers for HTTP1.X API server

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL