app

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package app contains the app server.

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
Package api contains the web services API.
Package api contains the web services 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.
currentuser
Package currentuser provides the services related to the current user.
Package currentuser provides the services related to the current user.
groups
Package groups provides API services to manage groups.
Package groups provides API services to manage groups.
items
Package items provides API services for items managing.
Package items provides API services for items managing.
threads
Package threads provides API services for threads managing.
Package threads provides API services for threads managing.
users
Package users provides API services for users managing.
Package users provides API services for users managing.
Package appenv provides utilities to configure the app environment (prod, dev, test).
Package appenv provides utilities to configure the app environment (prod, dev, test).
Package auth provides user authentication.
Package auth provides user authentication.
Package database provides an interface for database operations.
Package database provides an interface for database operations.
mysqldb
Package mysqldb contains database-related functions that are specific to mysql.
Package mysqldb contains database-related functions that are specific to mysql.
Package doc AlgoreaBackend API
Package doc AlgoreaBackend API
Package domain provides domain-specific configuration.
Package domain provides domain-specific configuration.
Package formdata provides an interface to handle forms.
Package formdata provides an interface to handle forms.
Package logging provides utilities for logging.
Package logging provides utilities for logging.
Package loggingtest provides functions to test the content of the logs.
Package loggingtest provides functions to test the content of the logs.
Package loginmodule provides functions related to user login.
Package loginmodule provides functions related to user login.
Package payloads defines data structures to be used as tokens.
Package payloads defines data structures to be used as tokens.
Package payloadstest contains token payloads to be used for tests.
Package payloadstest contains token payloads to be used for tests.
Package rand provides utilities to generate random data.
Package rand provides utilities to generate random data.
Package service provides utilities used for implementing services.
Package service provides utilities used for implementing services.
Package servicetest provides utilities to test services.
Package servicetest provides utilities to test services.
Package structures provides item-related structs.
Package structures provides item-related structs.
Package token provides a way to serialize/un-serialize data structures in an encrypted token.
Package token provides a way to serialize/un-serialize data structures in an encrypted token.
Package tokentest provides cryptographic keys to be used for tests.
Package tokentest provides cryptographic keys to be used for tests.
Package utils contains utility functions used by all modules.
Package utils contains utility functions used by all modules.
Package version exposes the app version
Package version exposes the app version

Jump to

Keyboard shortcuts

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