app

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthConfig

func AuthConfig(globalConfig *viper.Viper) *viper.Viper

AuthConfig returns an auth dynamic config from the global config (env var changes impacts values)

func DBConfig

func DBConfig(globalConfig *viper.Viper) (config *mysql.Config, err error)

DBConfig returns the db connection fixed config from the global config.

func DomainsConfig

func DomainsConfig(globalConfig *viper.Viper) (config []domain.ConfigItem, err error)

DomainsConfig returns the domains fixed config from the global config Panic in case of marshaling error.

func LoadConfig

func LoadConfig() *viper.Viper

LoadConfig loads and return the global configuration from files, flags, env, ... The precedence of config values in viper is the following: 1) explicit call to Set 2) flag (i.e., settable by command line) 3) env 4) config file 5) key/value store 6) default

func LoggingConfig

func LoggingConfig(globalConfig *viper.Viper) *viper.Viper

LoggingConfig returns a logging dynamic config from the global config (env var changes impacts values)

func ServerConfig

func ServerConfig(globalConfig *viper.Viper) *viper.Viper

ServerConfig returns a logging dynamic config from the global config (env var changes impacts values)

func TokenConfig

func TokenConfig(globalConfig *viper.Viper) (*token.Config, error)

TokenConfig returns the token fixed config from the global config

Types

type Application

type Application struct {
	HTTPHandler *chi.Mux
	Config      *viper.Viper
	Database    *database.DB
	// contains filtered or unexported fields
}

Application is the core state of the app

func New

func New() (*Application, error)

New configures application resources and routes.

func (*Application) CheckConfig

func (app *Application) CheckConfig() error

CheckConfig checks that the database contains all the data needed by the config

func (*Application) CreateMissingData

func (app *Application) CreateMissingData() error

CreateMissingData fills the database with required data (if missing)

func (*Application) ReplaceAuthConfig

func (app *Application) ReplaceAuthConfig(newGlobalConfig *viper.Viper)

ReplaceAuthConfig replaces the auth part of the config by the given one.

func (*Application) ReplaceDomainsConfig

func (app *Application) ReplaceDomainsConfig(newGlobalConfig *viper.Viper)

ReplaceDomainsConfig replaces the domains part of the config by the given one.

func (*Application) Reset

func (app *Application) Reset(config *viper.Viper) error

Reset reinitializes the application with the given config

type Server

type Server struct {
	*http.Server
}

Server provides an http.Server.

func NewServer

func NewServer(app *Application) (*Server, error)

NewServer creates and configures an APIServer serving all application routes.

func (*Server) Start

func (srv *Server) Start() chan bool

Start runs ListenAndServe on the http.Server with graceful shutdown.

Directories

Path Synopsis
api
answers
Package answers provides API services for task answers managing
Package answers provides API services for task answers managing
auth
Package auth provides API services related to authentication
Package auth provides API services related to authentication
contests
Package contests provides API services for contests managing
Package contests provides API services for contests managing
items
Package items provides API services for items managing
Package items provides API services for items managing
AlgoreaBackend API.
AlgoreaBackend API.

Jump to

Keyboard shortcuts

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