summaryrefslogtreecommitdiff
path: root/error.go
diff options
context:
space:
mode:
Diffstat (limited to 'error.go')
-rw-r--r--error.go19
1 files changed, 19 insertions, 0 deletions
diff --git a/error.go b/error.go
new file mode 100644
index 0000000..416d578
--- /dev/null
+++ b/error.go
@@ -0,0 +1,19 @@
+package mux
+
+import (
+ "context"
+ "encoding/json"
+ "io"
+)
+
+var DefaultErrorHandler func(err error) Renderer = func(err error) Renderer {
+ return RendererFunc(func(ctx context.Context, w io.Writer) error {
+ return json.NewEncoder(w).Encode(errorStruct{
+ Message: err.Error(),
+ })
+ })
+}
+
+type errorStruct struct {
+ Message string `json:"message"`
+}