Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(108)

Unified Diff: go/src/infra/tricium/service/common/common.go

Issue 2149853003: Adds checking of template error (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Adds infra testing expectation Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | go/src/infra/tricium/service/common/common.infra_testing » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/tricium/service/common/common.go
diff --git a/go/src/infra/tricium/service/common/common.go b/go/src/infra/tricium/service/common/common.go
new file mode 100644
index 0000000000000000000000000000000000000000..aeb6eee767c9efae61e1b3d830aa1f41b6f59b8d
--- /dev/null
+++ b/go/src/infra/tricium/service/common/common.go
@@ -0,0 +1,27 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Package common implements common functionality for the Tricium service modules.
+package common
+
+import (
+ "fmt"
+ "html/template"
+ "net/http"
+)
+
+var basePage = template.Must(template.ParseFiles("templates/base.html"))
+
+// ShowBasePage executes the base page template
+func ShowBasePage(w http.ResponseWriter, d interface{}) {
+ executeTemplate(basePage, w, d)
+}
+
+func executeTemplate(t *template.Template, w http.ResponseWriter, d interface{}) error {
+ if err := t.Execute(w, d); err != nil {
+ http.Error(w, "Internal server error. We are working on it.", http.StatusInternalServerError)
+ return fmt.Errorf("error executing template: %v", err)
+ }
+ return nil
+}
« no previous file with comments | « no previous file | go/src/infra/tricium/service/common/common.infra_testing » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698