コード例 #1
0
ファイル: handlers.go プロジェクト: tcard/goci
func handle_recent_json(w http.ResponseWriter, req *http.Request, ctx *Context) {
	ws, err := worker.GetRecentWork(ctx.Context, recent_amount)
	if err != nil {
		internal_error(w, req, ctx, err)
		return
	}
	if err := send_json(w, ws); err != nil {
		log.Println("error responding with json:", err)
	}
}
コード例 #2
0
ファイル: handlers.go プロジェクト: tcard/goci
func handle_recent_html(w http.ResponseWriter, req *http.Request, ctx *Context) {
	ws, err := worker.GetRecentWork(ctx.Context, recent_amount)
	if err != nil {
		internal_error(w, req, ctx, err)
		return
	}
	w.Header().Set("Content-Type", "text/html")
	err = recent_template.Execute(w, ws)
	if err != nil {
		internal_error(w, req, ctx, err)
	}
}
コード例 #3
0
ファイル: handlers.go プロジェクト: tcard/goci
//our basic handle index that demonstrates how to get data from the context
//inside a template
func handle_index(w http.ResponseWriter, req *http.Request, ctx *Context) {
	if req.URL.Path != "/" {
		perform_status(w, ctx, http.StatusNotFound)
		return
	}
	w.Header().Set("Content-type", "text/html")
	ws, err := worker.GetRecentWork(ctx.Context, recent_amount)
	if err != nil {
		internal_error(w, req, ctx, err)
		return
	}
	ctx.Set("Recent", ws)
	ctx.Meta.JS.Append("recent.js")
	base_execute(w, ctx, tmpl_root("blocks", "index.block"), tmpl_root("blocks", "recent.block"))
}