Esempio n. 1
0
func index(w http.ResponseWriter, r *http.Request) {
	// This must be added in order to Initialize the Application
	c := context.NewContext(r)
	// Handle hash fragments.
	if frag := r.URL.Query().Get("_escaped_fragment_"); frag != "" {
		c.Infof(`Search Engine Request: _escaped_fragment_: %v`, frag)
		fragHandler(w, r)
		return
	}
	// Handle not found.
	if r.URL.Path != "/" {
		p := r.URL.Path
		if strings.HasPrefix(p, "/-/") || strings.HasPrefix(p, "/_ah/") {
			http.Error(w, "404 Not found", http.StatusNotFound)
			return
		}
		// Redirect to hash so that angular routing can handle the request.
		hbp := "/#" + p
		http.Redirect(w, r, hbp, http.StatusFound)
		return
	}
	m := templateData()
	if err := indexTmpl.Execute(w, m); err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
	}
}
Esempio n. 2
0
// TODO implement this.
func fragHandler(w http.ResponseWriter, r *http.Request) {
	_ = context.NewContext(r)
	_ = r.URL.Query().Get("_escaped_fragment_")
	http.Error(w, "404 Not found", http.StatusNotFound)
}