Documentation ¶
Index ¶
- Constants
- func AddNoAuthRoutes(methodName string, methodType string, mRoute string, ...)
- func AddRoute(methodName, methodType, mRoute string, handlerFunc http.HandlerFunc)
- func AddRouteWithAuth(methodName, methodType, mRoute string, handlerFunc http.HandlerFunc, ...)
- func AddToContext(ctx context.Context, key, val interface{}) context.Context
- func ContextWithValue(ctx context.Context, val interface{}) context.Context
- func Count(db, collectionName string, findQ bson.M) (int64, error)
- func Create(ctx APIContext, db, collectionName string, d interface{}) (interface{}, error)
- func GetReuestID(ctx context.Context) string
- func GetS() (*mongo.Client, error)
- func HGet(listName, apikey string) (string, error)
- func HSet(listName, apikey string, timeval string) (bool, error)
- func LPop(listName string) (string, error)
- func RPush(listName, value string) (int64, error)
- func ReadAll(db, collectionName string, selector, filter bson.M, data interface{}) error
- func ReadOne(db, collectionName string, selector, filter bson.M, data interface{}) error
- func Start(port, subroute string)
- func ValidateToken(apikey, apisecret, requestID string) (context.Context, error)
- func WriteHTTPDataResponse(w http.ResponseWriter, statusCode int, msg string, data []byte)
- func WriteHTTPErrorResponse(w http.ResponseWriter, reqID, msg string, errorCode int, err error)
- func WriteHTTPResponse(w http.ResponseWriter, statusCode int, reqiestID, msg string, data interface{})
- type APIContext
- type DBConnection
- type MetaData
- type Response
- type Routes
Constants ¶
View Source
const ( //TransactionID for generating a random number for a request TransactionID = "transctionId" //RequestID of the parent request RequestID = "requestId" //Email address of the client UserID = "userID" )
View Source
const (
MobContext = "mobCtx"
)
Variables ¶
This section is empty.
Functions ¶
func AddNoAuthRoutes ¶
func AddNoAuthRoutes(methodName string, methodType string, mRoute string, handlerFunc http.HandlerFunc)
func AddRoute ¶
func AddRoute(methodName, methodType, mRoute string, handlerFunc http.HandlerFunc)
AddRoute is to create routes with ACL enforcer
func AddRouteWithAuth ¶
func AddRouteWithAuth(methodName, methodType, mRoute string, handlerFunc http.HandlerFunc, authentication func(http.HandlerFunc) http.HandlerFunc)
AddRouteWithAuth is to create routes with ACL enforcer
func Create ¶
func Create(ctx APIContext, db, collectionName string, d interface{}) (interface{}, error)
Create - inserts data into mongo database
func GetReuestID ¶
func GetS ¶
GetS returns session for database, if session is already created for database it returns session copy.
func ValidateToken ¶
func WriteHTTPDataResponse ¶
func WriteHTTPDataResponse(w http.ResponseWriter, statusCode int, msg string, data []byte)
func WriteHTTPErrorResponse ¶
func WriteHTTPErrorResponse(w http.ResponseWriter, reqID, msg string, errorCode int, err error)
func WriteHTTPResponse ¶
func WriteHTTPResponse(w http.ResponseWriter, statusCode int, reqiestID, msg string, data interface{})
Types ¶
type APIContext ¶
func GetContextData ¶
func GetContextData(ctx context.Context) APIContext
type DBConnection ¶
type DBConnection struct {
// contains filtered or unexported fields
}
type MetaData ¶
type MetaData struct { Code int `json:"code"` RequestID string `json:"requestId"` Message string `json:"message"` }
MetaData of HTTP API response
Click to show internal directories.
Click to hide internal directories.