config

package
v0.0.0-...-af1923c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2018 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HeaderHandler

func HeaderHandler(fieldKey, headerField string) func(next http.Handler) http.Handler

HeaderHandler adds the request's header field as a field to the context's logger using fieldKey as field key and headerField as the header field

Types

type Application

type Application struct {
	Middleware alice.Chain
	Logger     zerolog.Logger
	// contains filtered or unexported fields
}

Application properties of application

func LoadConfig

func LoadConfig(configPath, keyPath string) (application Application, err error)

LoadConfig loads configuration file properties from configPath file and optional keyPath encryption key

func (*Application) GetDatabaseConnection

func (a *Application) GetDatabaseConnection() (connection *mgo.Session, err error)

GetDatabaseConnection gets connection to database

func (*Application) GetSession

func (application *Application) GetSession(r *http.Request) *scs.Session

GetSession returns the session from the request

func (*Application) ListenAndServe

func (application *Application) ListenAndServe(handler http.Handler) error

ListenAndServe starts http server with supplied handler

func (*Application) StartSession

func (application *Application) StartSession(w http.ResponseWriter, r *http.Request, user *model.User) (session *scs.Session, err error)

StartSession creates session for given user

type Config

type Config struct {
	Db struct {
		Server   string
		Port     int
		Database string
		Username string
		Password string
	}
	Log struct {
		Path  string
		Level string
	}
	HTTP struct {
		Hostname string
		Port     int
	}
}

Config configuration file properties

Jump to

Keyboard shortcuts

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