//Run implements the rack.Middleware interface func (this Statuser) Run(vars map[string]interface{}, next func()) { next() status := httper.V(vars).GetStatus() layout := strconv.Itoa(status) if templater.V(vars).Exists(this.Folder + "/" + layout) { vars[this.LayoutVar] = layout return } layout = strconv.Itoa(status/100) + "xx" if templater.V(vars).Exists(this.Folder + "/" + layout) { vars[this.ErrorVar] = strconv.Itoa(status) vars[this.LayoutVar] = layout } }
// Implementation of rack.Middleware func (this Encapsulator) Run(vars map[string]interface{}, next func()) { next() layout, ok := vars[this.LayoutVar].(string) if !ok { logger.V(vars).Println("Layout not set") return } location := this.Folder + "/" + layout if !templater.V(vars).Exists(location) { //no "layout", just let it through logger.V(vars).Println("Layout \"" + layout + "\" not found") return } vars[this.BodyVar] = template.HTML(httper.V(vars).ResetMessage()) w := httper.V(vars).FilledResponse() templater.V(vars).Render(location, w) w.Save() }