40 lines
643 B
Go
40 lines
643 B
Go
package app
|
|
|
|
import (
|
|
"errors"
|
|
"log"
|
|
"os"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
type App struct {
|
|
e *echo.Echo
|
|
logger *log.Logger
|
|
initialised bool
|
|
}
|
|
|
|
// Init allows setting App's important fields - once.
|
|
func (a *App) Init() error {
|
|
if !a.initialised {
|
|
e := echo.New()
|
|
|
|
a.e = e
|
|
a.logger = log.New(os.Stderr, " *** pcmt:", log.Ldate|log.Ltime|log.Lshortfile)
|
|
a.initialised = true
|
|
|
|
return nil
|
|
}
|
|
return errors.New("ErrAppAlreadyInitialised")
|
|
}
|
|
|
|
// E returns app's *echo.Echo.
|
|
func (a *App) E() *echo.Echo {
|
|
return a.e
|
|
}
|
|
|
|
// Logger returns app's *log.Logger.
|
|
func (a *App) Logger() *log.Logger {
|
|
return a.logger
|
|
}
|