Beispiel #1
0
func (ro RouteHandler) View(w *webby.Web) {
	truth := ro.Init(w)

	if w.CutOut() {
		return
	}

	if !truth {
		w.Error403()
		return
	}

	var form *Form

	switch t := w.Session.(type) {
	case Form:
		form = &t
		w.DestroySession()
	case *Form:
		form = t
		w.DestroySession()
	default:
		form = ro.FetchForm(w)
	}

	if w.Req.Method == "POST" {
		goto post
	}

	if w.Req.URL.RawQuery != "" {
		if form.IsValid(w) {
			goto pass
		} else {
			goto get
		}
	}

get:
	ro.Get(w, form)
	return

post:
	if !form.IsValid(w) {
		goto fail
	}

pass:
	ro.PostPass(w)
	return

fail:
	w.SetSession(form)
	ro.PostFail(w)
}