summaryrefslogtreecommitdiff
path: root/error.go
diff options
context:
space:
mode:
authorAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-29 02:38:17 +0300
committerAlexander NeonXP Kiryukhin <i@neonxp.ru>2024-07-29 02:38:17 +0300
commit2916082d5ed94ef86ad58bdb7256ae07b214c4f3 (patch)
tree322a0e9172c07457a892f9737839843b8c584864 /error.go
Начальный коммит
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"`
+}