Exemple #1
0
func RetrieveProcess(res http.ResponseWriter, req *http.Request) {
	if p := proc[mux.Vars(req)["id"]]; p != nil {
		RespondJSON(res, p)
	} else {
		res.WriteHeader(http.StatusNotFound)
	}
}
func registration(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)

	u := User{
		Name:      "TestHendrik",
		StartDate: datastore.SecondsToTime(time.Seconds()),
	}

	if g := user.Current(c); g != nil {
		var u2 User
		u.Account = g.String()
		if err := datastore.Get(c, datastore.NewKey("user", g.String(), 0, nil), &u2); err == datastore.ErrNoSuchEntity {
			key, err := datastore.Put(c, datastore.NewKey("user", u.Account, 0, nil), &u)
			if err != nil {
				http.Error(w, err.String(), http.StatusInternalServerError)
				return
			}
			fmt.Fprintf(w, "User %q stored %q", u.Account, key)
			return
		} else {
			fmt.Fprintf(w, "User %q  is already logged in", g.String())
			return
		}
	} else {
		url, err := user.LoginURL(c, r.URL.String())
		if err != nil {
			http.Error(w, err.String(), http.StatusInternalServerError)
			return
		}
		w.Header().Set("Location", url)
		w.WriteHeader(http.StatusFound)
		return
	}

}
Exemple #3
0
func solutionsHandler(w http.ResponseWriter, r *http.Request) {

	hint := r.FormValue("hint")
	if hint == "" {
		w.WriteHeader(http.StatusInternalServerError)
		w.Header().Set("Content-Type", "text/plain;charset=UTF-8;")
		io.WriteString(w, "Required parameter 'hint' not received.\n")
		return
	}

	// Use a regexp to find all actual characters
	// we already know about
	realCharExp := regexp.MustCompile("[^*]")
	realChars := realCharExp.FindAllString(hint, -1)

	// Replace all '_' in the hint expression for
	// 'any character that's not currently known'
	newr_str := strings.Replace(hint, "*",
		fmt.Sprintf("[^%s]", strings.Join(realChars, "")), -1)
	finalExp := regexp.MustCompile(fmt.Sprintf("^%s$", newr_str))

	io.WriteString(w, fmt.Sprintf(`<html>
<head><title>Possible Solutions for %s</title></head>
<body><h1>Possible Solutions for %s</h1><ul>`, hint, hint))
	// Now go through the word list looking for matches
	for i := range wordList.Words() {
		if finalExp.MatchString(wordList.Word(i)) {
			io.WriteString(w, fmt.Sprintf("<li>%s</li>", wordList.Word(i)))
		}
	}
	io.WriteString(w, "</ul></body></html>")

}
Exemple #4
0
func handleReplaceForm(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	_, kind := path.Split(r.URL.Path)
	ser := DefaultMaster.delegator.Delegate(kind).(SerializerFormParser)
	s := ser.NewFromForm(r.Form)
	if s == nil {
		r.Form = nil
		w.SetHeader("Location", r.Referer)
		w.WriteHeader(302)
		return
	}
	ser.Replace(s)
	DefaultMaster.Save(s)
	out := bytes.NewBufferString("")
	host := s.Host()
	if host != "" {
		DefaultMaster.save(out, s)
		http.Post("http://"+host+DefaultMaster.replacePattern+kind, "application/octet-stream", out)
	} else {
		bc := DefaultMaster.delegator.(DelegatorBroadcaster)
		for _, h := range bc.Hosts() {
			out = bytes.NewBufferString("")
			DefaultMaster.save(out, s)
			http.Post("http://"+h+DefaultMaster.replacePattern+kind, "application/octet-stream", out)
		}
	}
	DefaultMaster.Logger.Printf("%v erfolgreich modifiziert", s.Log())
	redir := "http://" + r.Host + r.FormValue("Redir")
	w.SetHeader("Location", redir)
	w.WriteHeader(302)
}
Exemple #5
0
func handleAudit(w http.ResponseWriter, r *http.Request) {
	_, kind := path.Split(r.URL.Path)
	ip := r.FormValue("IP")
	ser := DefaultMaster.delegator.Delegate(kind)
	keys := ser.Keys()
	n := ser.Init()
	for _, v := range keys {
		ss := ser.At(v).(SerialSender)
		host := ss.Host()
		if host == ip || host == "" {
			n = n.Insert(ss)
		}
	}
	if len(n.Keys()) != 0 {
		w.SetHeader("Content-Encoding", "gzip")
		w.SetHeader("Content-Type", "application/octet-stream")
		err := DefaultMaster.SaveKind(w, n)
		if err != nil {
			DefaultMaster.Logger.Printf("Problem: Audit Typ %s mit Server %s fehlgeschlagen", n.Kind(), ip)
			w.WriteHeader(500)
		}
		return
	}
	w.WriteHeader(404)
}
Exemple #6
0
func handleDeleteForm(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	_, kind := path.Split(r.URL.Path)
	key := DefaultMaster.delegator.(DelegatorBroadcaster).KeyFromForm(r.Form)
	ser := DefaultMaster.delegator.Delegate(kind)
	keys := ser.Keys()
	n := ser.Init()
	for _, v := range keys {
		if v != key {
			n = n.Insert(ser.At(v))
		}
	}
	ser.All(n)
	s := ser.At(key).(SerialSender)
	DefaultMaster.Delete(s)
	out := bytes.NewBufferString("")
	host := s.Host()
	if host != "" {
		DefaultMaster.save(out, s)
		http.Post("http://"+host+DefaultMaster.deletePattern+kind, "application/octet-stream", out)
	} else {
		bc := DefaultMaster.delegator.(DelegatorBroadcaster)
		for _, h := range bc.Hosts() {
			out = bytes.NewBufferString("")
			DefaultMaster.save(out, s)
			http.Post("http://"+h+DefaultMaster.deletePattern+kind, "application/octet-stream", out)
		}
	}
	DefaultMaster.Logger.Printf("%v erfolgreich gelöscht", s.Log())
	redir := "http://" + r.Host + r.FormValue("Redir")
	w.SetHeader("Location", redir)
	w.WriteHeader(302)
}
Exemple #7
0
func handleGet(w http.ResponseWriter) {
	w.Header().Set("Content-Type", "text/plain")
	w.WriteHeader(405)
	fmt.Fprintf(w, "405 Method Not Allowed\n\n"+
		"To access this amf.go gateway you must use POST requests "+
		"(%s received))")
}
Exemple #8
0
func main(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	u := user.Current(c)

	if u == nil {
		url, err := user.LoginURL(c, r.URL.String())
		if err != nil {
			http.Error(w, err.String(), http.StatusInternalServerError)
			return
		}
		w.Header().Set("Location", url)
		w.WriteHeader(http.StatusFound)
		return
	}

	tok, err := AddClient(c, u.Id)
	if err != nil {
		http.Error(w, err.String(), 500)
		return
	}

	err = mainTemplate.Execute(w, map[string]string{
		"token":        tok,
		"client_id":    u.Id,
		"client_email": u.Email,
	})

	if err != nil {
		c.Errorf("mainTemplate: %v", err)
	}

}
Exemple #9
0
func runFunc(c appengine.Context, w http.ResponseWriter, req *http.Request) {
	defer req.Body.Close()

	var inv invocation
	if err := gob.NewDecoder(req.Body).Decode(&inv); err != nil {
		c.Errorf("delay: failed decoding task payload: %v", err)
		c.Warningf("delay: dropping task")
		return
	}

	f := funcs[inv.Key]
	if f == nil {
		c.Errorf("delay: no func with key %q found", inv.Key)
		c.Warningf("delay: dropping task")
		return
	}

	// TODO: This is broken for variadic functions.
	ft := f.fv.Type()
	in := make([]reflect.Value, ft.NumIn())
	in[0] = reflect.ValueOf(c)
	for i := 1; i < len(in); i++ {
		in[i] = reflect.ValueOf(inv.Args[i-1])
	}
	out := f.fv.Call(in)

	if n := ft.NumOut(); n > 0 && ft.Out(n-1) == osErrorType {
		if errv := out[n-1]; !errv.IsNil() {
			c.Errorf("delay: func failed (will retry): %v", errv.Interface())
			w.WriteHeader(http.StatusInternalServerError)
			return
		}
	}
}
Exemple #10
0
func handleCreate(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	u := user.Current(c)
	if u == nil {
		return
	}

	r.ParseForm()
	url := r.FormValue("url")
	title := r.FormValue("title")
	tagString := r.FormValue("tags")
	if url == "" {
		output(c, w, "create")
		return
	}

	tags := strings.Split(tagString, ",")
	bm := bookmarks.NewBookmark(u, url, title, tags)
	_, err := bm.Save(c)
	if err != nil {
		http.Error(w, err.String(), http.StatusInternalServerError)
		return
	}

	w.Header().Set("Location", rootURL(c))
	w.WriteHeader(http.StatusFound)
	return
}
Exemple #11
0
func gamesPost(w http.ResponseWriter, r *http.Request, u *user.User, c appengine.Context) {

	game := Game{
		P1:     r.FormValue("player1"),
		P2:     r.FormValue("player2"),
		Played: datastore.SecondsToTime(time.Seconds()),
	}
	scorefields := map[string]int{
		"Player1score": 0,
		"Player2score": 0,
	}
	for k, _ := range scorefields {
		score, err := strconv.Atoi(r.FormValue(k))
		if err != nil {
			http.Error(w, err.String(), http.StatusInternalServerError)
			return
		}
		scorefields[k] = score
	}
	game.P1score = scorefields["Player1score"]
	game.P2score = scorefields["Player2score"]

	_, err := datastore.Put(c, datastore.NewIncompleteKey("Game"), &game)
	if err != nil {
		http.Error(w, err.String(), http.StatusInternalServerError)
		return
	}

	rurl := fmt.Sprintf("http://%v/", r.Host)
	w.Header().Set("Location", rurl)
	w.WriteHeader(http.StatusFound)
}
Exemple #12
0
func ReturnJson(conn http.ResponseWriter, data interface{}) {
	conn.Header().Set("Content-Type", "text/javascript")

	if m, ok := data.(map[string]interface{}); ok {
		statusCode := 0
		if t, ok := m["error"].(string); ok && len(t) > 0 {
			statusCode = http.StatusInternalServerError
		}
		if t, ok := m["errorType"].(string); ok {
			switch t {
			case "server":
				statusCode = http.StatusInternalServerError
			case "input":
				statusCode = http.StatusBadRequest
			}
		}
		if statusCode != 0 {
			conn.WriteHeader(statusCode)
		}
	}

	bytes, err := json.MarshalIndent(data, "", "  ")
	if err != nil {
		BadRequestError(conn, fmt.Sprintf(
			"JSON serialization error: %v", err))
		return
	}
	conn.Write(bytes)
	conn.Write([]byte("\n"))
}
Exemple #13
0
func handleVerify(conn http.ResponseWriter, req *http.Request) {
	if !(req.Method == "POST" && req.URL.Path == "/camli/sig/verify") {
		httputil.BadRequestError(conn, "Inconfigured handler.")
		return
	}

	req.ParseForm()
	sjson := req.FormValue("sjson")
	if sjson == "" {
		httputil.BadRequestError(conn, "Missing sjson parameter.")
		return
	}

	m := make(map[string]interface{})

	vreq := jsonsign.NewVerificationRequest(sjson, pubKeyFetcher)
	if vreq.Verify() {
		m["signatureValid"] = 1
		m["verifiedData"] = vreq.PayloadMap
	} else {
		errStr := vreq.Err.String()
		m["signatureValid"] = 0
		m["errorMessage"] = errStr
	}

	conn.WriteHeader(http.StatusOK) // no HTTP response code fun, error info in JSON
	httputil.ReturnJson(conn, m)
}
Exemple #14
0
func evServer(w http.ResponseWriter, r *http.Request) {
	wevs := make(chan store.Event)
	path := r.URL.Path[len("/$events"):]

	glob, err := store.CompileGlob(path + "**")
	if err != nil {
		w.WriteHeader(400)
		return
	}

	rev, _ := Store.Snap()

	go func() {
		walk(path, Store, wevs)
		for {
			ch, err := Store.Wait(glob, rev+1)
			if err != nil {
				break
			}
			ev, ok := <-ch
			if !ok {
				break
			}
			wevs <- ev
			rev = ev.Rev
		}
		close(wevs)
	}()

	websocket.Handler(func(ws *websocket.Conn) {
		send(ws, path, wevs)
		ws.Close()
	}).ServeHTTP(w, r)
}
Exemple #15
0
func ServeDataItemPage(writer http.ResponseWriter, request *http.Request) {
	if strings.Contains(request.Header.Get("Accept"), "application/json") {
		writer.Header().Set("Content-Type", "applicaton/json")
	} else {
		writer.Header().Set("Content-Type", "text/plain")
	}

	stream := StreamByName("ranger")

	log.Printf("Serving full data for '%s'", request.FormValue("q"))
	data := stream.LookupData(request.FormValue("q"))
	if data == nil {
		log.Printf("Failed to find %s", request.FormValue("q"))
		writer.WriteHeader(http.StatusNotFound)
		return
	}

	outputBytes, err := json.MarshalIndent(data, "", "  ")
	if err != nil {
		log.Printf("Failed to format data")
		writer.WriteHeader(http.StatusInternalServerError)
		return
	}

	writer.Write(outputBytes)
}
Exemple #16
0
func (v *jsonView) handle(w http.ResponseWriter, req *http.Request, s *session) {
	if v.checkUniqueURL != "" && req.URL.Path != v.checkUniqueURL {
		w.WriteHeader(http.StatusNotFound)
		fmt.Fprintf(w, "<pre>404 page not found</pre>")
		return
	}

	d := func() (ret interface{}) {
		defer func() {
			if e := recover(); e != nil {
				if gde, ok := e.(getDataError); ok {
					ret = gde
				} else if ose, ok := e.(os.Error); ok {
					ret = getDataError{http.StatusInternalServerError, ose}
				} else {
					ret = getDataError{http.StatusInternalServerError, os.NewError(fmt.Sprintf("%v", e))}
				}
			}
		}()
		return v.getData(req, s)
	}()

	dd, e := json.Marshal(d)
	if e != nil {
		fmt.Fprintf(w, "{Code: 500, Error: %#v}", e.String())
	} else {
		w.Write(dd)
	}
}
Exemple #17
0
func postHandler(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	if cv := req.FormValue("cookie"); cv != "" {
		trace("postHandler recieved param cookie %s.", cv)
		cp := strings.SplitN(cv, "=", 2)
		if cp[1] != "-DELETE-" {
			exp := time.SecondsToUTC(time.UTC().Seconds() + 7*24*3600).Format(http.TimeFormat) // Now + 7 days
			w.Header().Set("Set-Cookie", fmt.Sprintf("%s=%s; Path=/de/index; expires=%s; Domain=my.domain.org; Secure;", cp[0], cp[1], exp))
		} else {
			trace("post-handler: Deleting cookie %s\n", cp[0])
			w.Header().Set("Set-Cookie", fmt.Sprintf("%s=%s; Path=/de/index; MaxAge=-1; Domain=my.domain.org; Secure;", cp[0], "X"))
		}
	}
	t := req.FormValue("q")
	if req.Method != "POST" {
		fmt.Printf("====== called /post with GET! ======\n")
	}

	_, header, err := req.FormFile("datei")
	if err == nil {
		info("Recieved datei: %s. %v", header.Filename, header.Filename == "file äöü 1.txt")
	}

	if t != "" {
		// w.Header().Set("Location", "http://localhost:54123/"+t)
		// w.Header().Set("Location", "localhost:54123/"+t)
		w.Header().Set("Location", "/"+t)
		w.WriteHeader(302)
	} else {
		text := req.FormValue("text")
		w.WriteHeader(200)
		body := "<html><body><h1>Post Page</h1><p>t = " + html.EscapeString(text) + "</p></body></html>"
		w.Write([]byte(body))
	}
}
Exemple #18
0
func cookieHandler(w http.ResponseWriter, req *http.Request) {
	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	if cn := req.FormValue("set"); cn != "" {
		cv, cp := req.FormValue("val"), req.FormValue("pat")
		trace("cookieHandler recieved cookie %s=%s; path=%s.", cn, cv, cp)
		w.Header().Set("Set-Cookie", fmt.Sprintf("%s=%s; Path=/de/index; Domain=my.domain.org; Secure;", cn, cv))
	}

	if t := req.FormValue("goto"); t != "" {
		w.Header().Set("Location", "localhost:54123/"+t)
		w.WriteHeader(302)
	} else {
		w.WriteHeader(200)
		body := "<html><head><title>Cookies</title></head>\n<body><h1>All Submitted Cookies</h1>"
		for _, cookie := range req.Cookies() {
			body += "<div class=\"cookies\">\n"
			body += "  <ul>\n"
			body += "   <li>" + cookie.Name + " :: " + cookie.Value + "</li>\n"
			body += "  </ul>\n"
			body += "</div>\n"
		}
		body += "</body></html>"
		w.Write([]byte(body))
	}
}
Exemple #19
0
func StartTiling(w http.ResponseWriter, req *http.Request) {
	if reset != nil {
		select {
		case <-reset:
			reset <- 1
		case reset <- 1:
		}
	}

	tilingType := req.FormValue("type")
	tileSymmetry := req.FormValue("symmetry")

	if tilingType == "skeleton" {
		skeleton := req.FormValue("skeleton")
		showIntermediate, ok := strconv.Atob(req.FormValue("intermediate"))
		if ok != nil || skeleton == "" {
			w.WriteHeader(http.StatusNotFound)
		}
		ZellijTilings, reset = zellij.TileSkeleton(skeleton, tileSymmetry, showIntermediate)
		w.WriteHeader(http.StatusOK)
		return
	} else if tilingType == "plane" {
		maxtiles, okm := strconv.Atoi(req.FormValue("maxtiles"))
		showIntermediate, oks := strconv.Atob(req.FormValue("intermediate"))
		if okm != nil || oks != nil || maxtiles == 0 {
			w.WriteHeader(http.StatusNotFound)
		}
		ZellijTilings, reset = zellij.TilePlane(maxtiles, tileSymmetry, showIntermediate)
		w.WriteHeader(http.StatusOK)
		return
	}

	w.WriteHeader(http.StatusNotFound)
}
Exemple #20
0
func join(w http.ResponseWriter, r *http.Request) {
	c := appengine.NewContext(r)
	u := user.Current(c)
	if u == nil {
		url, err := user.LoginURL(c, r.URL.String())
		if err != nil {
			http.Error(w, err.String(), http.StatusInternalServerError)
			return
		}
		w.Header().Set("Location", url)
		w.WriteHeader(http.StatusFound)
		return
	}
	r.ParseForm()
	// TODO check table arg
	state, err := joinTable(c, r.Form["table"][0], u.String())
	if err != nil {
		http.Error(w, err.String(), http.StatusInternalServerError)
		return
	}
	var b []byte
	b, err = json.Marshal(state)
	if err != nil {
		http.Error(w, err.String(), http.StatusInternalServerError)
		return
	}
	fmt.Fprintf(w, "%s", b)
}
Exemple #21
0
Fichier : host.go Projet : ssrl/go
func (h *Handler) handleInternalRedirect(rw http.ResponseWriter, req *http.Request, path string) {
	url, err := req.URL.ParseURL(path)
	if err != nil {
		rw.WriteHeader(http.StatusInternalServerError)
		h.printf("cgi: error resolving local URI path %q: %v", path, err)
		return
	}
	// TODO: RFC 3875 isn't clear if only GET is supported, but it
	// suggests so: "Note that any message-body attached to the
	// request (such as for a POST request) may not be available
	// to the resource that is the target of the redirect."  We
	// should do some tests against Apache to see how it handles
	// POST, HEAD, etc. Does the internal redirect get the same
	// method or just GET? What about incoming headers?
	// (e.g. Cookies) Which headers, if any, are copied into the
	// second request?
	newReq := &http.Request{
		Method:     "GET",
		URL:        url,
		RawURL:     path,
		Proto:      "HTTP/1.1",
		ProtoMajor: 1,
		ProtoMinor: 1,
		Header:     make(http.Header),
		Host:       url.Host,
		RemoteAddr: req.RemoteAddr,
		TLS:        req.TLS,
	}
	h.PathLocationHandler.ServeHTTP(rw, newReq)
}
Exemple #22
0
func (h *JSONSignHandler) handleVerify(rw http.ResponseWriter, req *http.Request) {
	req.ParseForm()
	sjson := req.FormValue("sjson")
	if sjson == "" {
		http.Error(rw, "missing \"sjson\" parameter", http.StatusBadRequest)
		return
	}

	m := make(map[string]interface{})

	// TODO: use a different fetcher here that checks memory, disk,
	// the internet, etc.
	fetcher := h.pubKeyFetcher

	vreq := jsonsign.NewVerificationRequest(sjson, fetcher)
	if vreq.Verify() {
		m["signatureValid"] = 1
		m["signerKeyId"] = vreq.SignerKeyId
		m["verifiedData"] = vreq.PayloadMap
	} else {
		errStr := vreq.Err.String()
		m["signatureValid"] = 0
		m["errorMessage"] = errStr
	}

	rw.WriteHeader(http.StatusOK) // no HTTP response code fun, error info in JSON
	httputil.ReturnJson(rw, m)
}
Exemple #23
0
func (redirector *HTTPRedirector) ServeHTTP(conn http.ResponseWriter, req *http.Request) {

	if req.URL.Path == redirector.PingPath {
		headers := conn.Header()
		headers.Set("Content-Type", "text/plain")
		headers.Set("Content-Length", redirector.PongLength)
		conn.WriteHeader(http.StatusOK)
		conn.Write(redirector.Pong)
		redirector.Log(HTTP_PING, http.StatusOK, req.Host, req)
		return
	}

	var url string
	if len(req.URL.RawQuery) > 0 {
		url = fmt.Sprintf("%s%s?%s", redirector.URL, req.URL.Path, req.URL.RawQuery)
	} else {
		url = fmt.Sprintf("%s%s", redirector.URL, req.URL.Path)
	}

	if len(url) == 0 {
		url = "/"
	}

	if redirector.HSTS != "" {
		conn.Header().Set("Strict-Transport-Security", redirector.HSTS)
	}

	conn.Header().Set("Location", url)
	conn.WriteHeader(http.StatusMovedPermanently)
	fmt.Fprintf(conn, redirector.Message, url)
	redirector.Log(HTTP_REDIRECT, http.StatusMovedPermanently, req.Host, req)

}
Exemple #24
0
func listCardHandler(w http.ResponseWriter, req *http.Request) {
	if req.Method == "GET" {
		listCards(w)
	} else {
		w.WriteHeader(400)
	}
}
Exemple #25
0
// error writes compile, link, or runtime errors to the HTTP connection.
// The JavaScript interface uses the 404 status code to identify the error.
func error(w http.ResponseWriter, out []byte, err os.Error) {
	w.WriteHeader(404)
	if out != nil {
		output.Execute(w, out)
	} else {
		output.Execute(w, err.String())
	}
}
Exemple #26
0
func (frontend *Frontend) ServeError502(conn http.ResponseWriter, host string, request *http.Request) {
	headers := conn.Header()
	headers.Set("Content-Type", "text/html; charset=utf-8")
	headers.Set("Content-Length", frontend.Error502Length)
	conn.WriteHeader(http.StatusBadGateway)
	conn.Write(frontend.Error502)
	frontend.Log(HTTPS_PROXY_ERROR, http.StatusBadGateway, host, request)
}
Exemple #27
0
// senderr, when deferred, recovers panics of
// type sendHTTPStatus and writes the corresponding
// HTTP status to the response.  If the value is not
// of type sendHTTPStatus, it re-panics.
func senderr(w http.ResponseWriter) {
	err := recover()
	if stat, ok := err.(sendHTTPStatus); ok {
		w.WriteHeader(int(stat))
	} else if err != nil {
		panic(err)
	}
}
Exemple #28
0
func RootServer(w http.ResponseWriter, req *http.Request) {
	if template, err := ioutil.ReadFile("index.html"); err == nil {
		w.Write(template)
	} else {
		w.WriteHeader(500)
		w.Write([]byte("Could not open template file"))
	}
}
Exemple #29
0
func writeTemplate(w http.ResponseWriter, tempFile string, model interface{}) {
	if tpl, err := template.ParseFile(tempFile); err != nil {
		fmt.Fprintf(w, "Internal Server Error")
		w.WriteHeader(500)
	} else {
		tpl.Execute(w, model)
	}
}
Exemple #30
0
func (frontend *Frontend) ServeError500(conn http.ResponseWriter, host string, request *http.Request) {
	headers := conn.Header()
	headers.Set("Content-Type", "text/html; charset=utf-8")
	headers.Set("Content-Length", frontend.Error500Length)
	conn.WriteHeader(http.StatusInternalServerError)
	conn.Write(frontend.Error500)
	frontend.Log(HTTPS_INTERNAL_ERROR, http.StatusInternalServerError, host, request)
}