Example #1
0
// With layout by given name
func (t Tmpl) With(name string, context interface{}) *Layout {
	logr.Debugf("Layout: %s", name)
	l := t.Templates()
	for _, lt := range l {
		logr.Debug(lt.Name())
	}
	return &Layout{
		tmpl:    t,
		context: context,
		name:    name,
	}
}
Example #2
0
// ServeHTTP implementation of http.Handler
func (h hosts) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	host := strings.Split(r.Host, ":")[0]
	parts := strings.Split(host, ".")
	for len(parts) > 0 {
		name := strings.Join(parts, ".")
		logr.Debug(name)
		if e, ok := h[name]; ok && e != nil {
			e.ServeHTTP(w, r)
			return
		}
		parts = parts[0 : len(parts)-1]
	}

	http.Error(w, "Domain not recognised", http.StatusNotFound)
}