app

package
v0.0.0-...-956ff96 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRouter

func CreateRouter(apiPrefix string, appVersion *handlers.Version, idMappers *idmappers.IDMappers) *mux.Router

CreateRouter creates http router

Types

type App

type App struct {
	Version       *handlers.Version
	Configuration *Configuration
	RedisClient   *redis.Client
	DB            *sql.DB
	IDMappers     *idmappers.IDMappers
	// contains filtered or unexported fields
}

App consists of application configurationand resources

func NewApp

func NewApp(version string, commit string, build string, configFile string) (*App, error)

NewApp creates new App with its configuration and logger

func (App) PrintConfiguration

func (app App) PrintConfiguration()

PrintConfiguration prints configuration to stdout

func (*App) Run

func (app *App) Run(done chan os.Signal)

Run starts app by running http server

func (*App) SetupIDMappers

func (app *App) SetupIDMappers() error

SetupIDMappers creates IDMappers

func (*App) SetupPostgreSQL

func (app *App) SetupPostgreSQL() error

SetupPostgreSQL opens connection to PostgresSQL (useful during testing when using sql mock)

func (*App) SetupRedis

func (app *App) SetupRedis()

SetupRedis creates redis client (useful during testing when using redis mock)

type Configuration

type Configuration struct {
	Addr       string           `mapstructure:"addr"`
	APIPrefix  string           `mapstructure:"api_prefix"`
	Logger     LoggerConfig     `mapstructure:"logger"`
	Redis      RedisConfig      `mapstructure:"redis"`
	PostgreSQL PostgreSQLConfig `mapstructure:"postgresql"`
	IDMappers  idmappers.Config `mapstructure:"idmappers"`
}

Configuration application configuration

type LoggerConfig

type LoggerConfig struct {
	JSON bool `mapstructure:"json"`
}

LoggerConfig application configuration for Logger

type PostgreSQLConfig

type PostgreSQLConfig struct {
	ConnectionString string `mapstructure:"connection_string"`
}

PostgreSQLConfig application configuration for PostgreSQL

type RedisConfig

type RedisConfig struct {
	Addr     string `mapstructure:"addr"`
	Password string `mapstructure:"password"`
}

RedisConfig application configuration for Redis

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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