microapp

package module
v0.0.46 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2019 License: MIT Imports: 14 Imported by: 0

README

microapp

Simple microservice framework in go!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Name   string
	Config *config.Config
	DB     *gorm.DB
	Router *mux.Router
	// contains filtered or unexported fields
}

App structure for tenant microservice

func New

func New(appName string, appConfigOverride map[string]string, appLog *log.Logger, appDB *gorm.DB, appEventDispatcher event.EventDispatcher) *App

New creates a new microApp

func (*App) DispatchEvent

func (app *App) DispatchEvent(token string, topic string, payload interface{})

DispatchEvent delegates to eventDispatcher.

func (*App) Initialize

func (app *App) Initialize(routeSpecifiers []RouteSpecifier)

Initialize initializes properties of the app

func (*App) Logger

func (app *App) Logger(module string) *log.Entry

Logger returns logger for specified module

func (*App) NewUnitOfWork added in v0.0.2

func (app *App) NewUnitOfWork(readOnly bool) *repository.UnitOfWork

NewUnitOfWork creates new UnitOfWork

func (*App) Start

func (app *App) Start()

Start http server and start listening to the requests

func (*App) Stop

func (app *App) Stop()

Stop http server

type RouteSpecifier

type RouteSpecifier interface {
	RegisterRoutes(router *mux.Router)
}

RouteSpecifier should be implemented by the class that sets routes for the API endpoints

type TestApp added in v0.0.7

type TestApp struct {
	// contains filtered or unexported fields
}

TestApp Provides convinience methods for test

func NewTestApp added in v0.0.7

func NewTestApp(appName string, controllerRouteProvider func(*App) []RouteSpecifier, dbInitializer func(db *gorm.DB), verbose bool) *TestApp

NewTestApp returns new instance of TestApp

func (*TestApp) CheckResponseCode added in v0.0.7

func (testApp *TestApp) CheckResponseCode(t *testing.T, expected, actual int)

CheckResponseCode checks if the http response is as expected

func (*TestApp) ExecuteRequest added in v0.0.7

func (testApp *TestApp) ExecuteRequest(req *http.Request) *httptest.ResponseRecorder

ExecuteRequest executes the http request

func (*TestApp) GetAdminToken added in v0.0.8

func (testApp *TestApp) GetAdminToken(tenantID string, userID string, scope []string) string

GetAdminToken returns a test token

func (*TestApp) GetFullAdminToken added in v0.0.46

func (testApp *TestApp) GetFullAdminToken(tenantID string, userID string, username string, name string, externalID string, externalIDType string, scope []string) string

GetFullAdminToken returns a test token with all the fields along with different external IDs for types such as Appliance, Session, User. These external IDs are used with REST api is invoked from another REST API service as opposed to the getting hit from UI by the user.

func (*TestApp) GetFullToken added in v0.0.45

func (testApp *TestApp) GetFullToken(tenantID string, userID string, username string, name string, externalID string, externalIDType string, scope []string) string

GetFullToken returns a test token with all the fields along with different external IDs for types such as Appliance, Session, User. These external IDs are used with REST api is invoked from another REST API service as opposed to the getting hit from UI by the user.

func (*TestApp) GetToken added in v0.0.7

func (testApp *TestApp) GetToken(tenantID string, userID string, scope []string) string

GetToken gets a token to connect to API

func (*TestApp) Initialize added in v0.0.7

func (testApp *TestApp) Initialize()

Initialize prepares the app for testing

func (*TestApp) PrepareEmptyTables added in v0.0.7

func (testApp *TestApp) PrepareEmptyTables()

PrepareEmptyTables clears all table of data

func (*TestApp) Stop added in v0.0.7

func (testApp *TestApp) Stop()

Stop the app

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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