Ejemplo n.º 1
0
// create a new http frontend give frontend config
func NewHTTPFrontend(c *config.FrontendConfig, db database.DB) (f Frontend, err error) {

	var markupCache cache.CacheInterface

	markupCache, err = cache.FromConfig(c.Cache)
	if err != nil {
		return
	}

	var mid Middleware
	if c.Middleware != nil {
		// middleware configured
		mid, err = OverchanMiddleware(c.Middleware, markupCache, db)
	}

	if err == nil {
		// create http frontend only if no previous errors
		f, err = createHttpFrontend(c, mid, db)
	}
	return
}
Ejemplo n.º 2
0
// reload http frontend
// reloads middleware
func (f *httpFrontend) Reload(c *config.FrontendConfig) {
	if f.middleware == nil {
		if c.Middleware != nil {
			markupcache, err := cache.FromConfig(c.Cache)
			if err == nil {
				// no middleware set, create middleware
				f.middleware, err = OverchanMiddleware(c.Middleware, markupcache, f.db)
				if err != nil {
					log.Errorf("overchan middleware reload failed: %s", err.Error())
				}
			} else {
				// error creating cache
				log.Errorf("failed to create cache: %s", err.Error())
			}
		}
	} else {
		// middleware exists
		// do middleware reload
		f.middleware.Reload(c.Middleware)
	}

}