core

package
v0.0.0-...-1cba5f3 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2020 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

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 AddToContext

func AddToContext(ctx context.Context, key, val interface{}) context.Context

func ContextWithValue

func ContextWithValue(ctx context.Context, val interface{}) context.Context

func Count

func Count(db, collectionName string, findQ bson.M) (int64, error)

Count returns number of documents those satisfied findQuery

func Create

func Create(ctx APIContext, db, collectionName string, d interface{}) (interface{}, error)

Create - inserts data into mongo database

func GetReuestID

func GetReuestID(ctx context.Context) string

func GetS

func GetS() (*mongo.Client, error)

GetS returns session for database, if session is already created for database it returns session copy.

func HGet

func HGet(listName, apikey string) (string, error)

func HSet

func HSet(listName, apikey string, timeval string) (bool, error)

func LPop

func LPop(listName string) (string, error)

func RPush

func RPush(listName, value string) (int64, error)

func ReadAll

func ReadAll(db, collectionName string, selector, filter bson.M, data interface{}) error

ReadAll - inserts data into mongo database

func ReadOne

func ReadOne(db, collectionName string, selector, filter bson.M, data interface{}) error

ReadOne - inserts data into mongo database

func Start

func Start(port, subroute string)

Start - http servers

func ValidateToken

func ValidateToken(apikey, apisecret, requestID string) (context.Context, error)

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

type APIContext struct {
	APIKey       string
	APIKeySecret string
	Email        string
	RequestID    string
}

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

type Response

type Response struct {
	Meta MetaData    `json:"meta"`
	Data interface{} `json:"data,omitempty"`
}

Response - complete structure of HTTP response Meta + Data

type Routes

type Routes []route

Routes - list of route

Jump to

Keyboard shortcuts

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