server

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOGGER = iota + 1
	BUILDER
	ROUTER
	CACHE
)
View Source
const DEFAULT = "default"

Variables

View Source
var (
	ErrConfigNotLoaded = errors.New("server: config is not loaded")
)
View Source
var (
	ErrNoRouterConfig = errors.New("server: no router is configured")
)

Functions

func Builder

func Builder(name string) (sqlquery.Builder, error)

Builder returns the configured database. If no database is defined, the builder will be nil.

func Cache

func Cache(name string) (cache.Interface, error)

Cache returns the configured cache. If no cache is defined, this will be nil.

func Initialize

func Initialize(config interface{}, hooks ...int) error

Initialize is init the log, builder, router and cache by config.

func Logger

func Logger() *logger.Logger

Logger returns the default log. Logger is always defined.

func Router

func Router() *router.Manager

Cache returns the configured cache. If no cache is defined, this will be nil.

func Run

func Run() error

Run the web-server

Types

type CacheProvider

type CacheProvider struct {
	Provider string `json:"provider" validate:"required"`
	GCCycle  int64  `json:"cycle" validate:"required"` // int * Minutes
}

type Config

type Config struct {
	Databases    []*sqlquery.Config `json:"databases" validate:"min=1"`
	Server       Server             `json:"server" validate:"required"`
	Router       RouterProvider     `json:"router" validate:"required"`
	CacheManager []CacheProvider    `json:"caches" validate:"min=1"`
}

type RouterProvider

type RouterProvider struct {
	Provider    string      `json:"provider" validate:"required"`
	Favicon     string      `json:"favicon"`
	Directories []UrlSource `json:"directories"`
	Files       []UrlSource `json:"files"`
}

type Server

type Server struct {
	Domain   string `json:"domain" validate:"required"`
	Language string `json:"language" validate:"required"`
	TimeZone string `json:"timezone" validate:"required"`
	HTTPPort int    `json:"httpPort" validate:"required"`
	AppPath  string `json:"appPath" validate:"required"`
}

type UrlSource

type UrlSource struct {
	Url    string `json:"url"`
	Source string `json:"source"`
}

Jump to

Keyboard shortcuts

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