summaryrefslogtreecommitdiff
path: root/system/admin/admin.go
diff options
context:
space:
mode:
authorSteve <nilslice@gmail.com>2017-01-26 10:48:40 -0800
committerGitHub <noreply@github.com>2017-01-26 10:48:40 -0800
commit16a159acec94fd391e840fab061ed08cf894369f (patch)
tree3418b9e58c9b967171bb5e5138a36cae3384f5c5 /system/admin/admin.go
parent3dea30f62a274db3e0cc95441338b2b71a751198 (diff)
[core] Embedded and implement http.Pusher into http.ResponseWriter+gzip Writer (#47)
* added http Pusher interface to gzip response writer * implement Pusher on gzipResponseWriter and pass encoding header to pusher options * providing a generic error view fuction for code that calls a interface method which will have access to the response * fix []byte -> string type for fmt string * adding the res, req pattern for method arguments in interfaces and their method calls * fix for spacing in generic error message * remove default error views displayed in lifecycle hooks - will rely on custom views or redirects inside hook now that user has ResponseWriter. Otherwise, multiple WriteHeader calls would be warned * removing WriteHeader calls before return in external handlers * bump version 0.8.1
Diffstat (limited to 'system/admin/admin.go')
-rw-r--r--system/admin/admin.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/system/admin/admin.go b/system/admin/admin.go
index 3df6805..7761e71 100644
--- a/system/admin/admin.go
+++ b/system/admin/admin.go
@@ -5,6 +5,7 @@ package admin
import (
"bytes"
"encoding/json"
+ "fmt"
"html/template"
"net/http"
@@ -607,3 +608,22 @@ var err500HTML = []byte(`
func Error500() ([]byte, error) {
return Admin(err500HTML)
}
+
+var errMessageHTML = `
+<div class="error-page eMsg col s6">
+<div class="card">
+<div class="card-content">
+ <div class="card-title"><b>Error:&nbsp;</b>%s</div>
+ <blockquote>%s</blockquote>
+</div>
+</div>
+</div>
+`
+
+// ErrorMessage is a generic error message container, similar to Error500() and
+// others in this package, ecxept it expects the caller to provide a title and
+// message to describe to a view why the error is being shown
+func ErrorMessage(title, message string) ([]byte, error) {
+ eHTML := fmt.Sprintf(errMessageHTML, title, message)
+ return Admin([]byte(eHTML))
+}