summaryrefslogblamecommitdiff
path: root/error.go
blob: f85174e89e7779689c58467a4e0ef0f56dc3489c (plain) (tree)
1
2
3
4
5
6
7
8
9




                       
                  


                                                                             
                                                                                    








                                                             
package mux

import (
	"context"
	"encoding/json"
	"net/http"
)

var DefaultErrorHandler func(err error) Renderer = func(err error) Renderer {
	return RendererFunc(func(ctx context.Context, w http.ResponseWriter) error {
		return json.NewEncoder(w).Encode(errorStruct{
			Message: err.Error(),
		})
	})
}

type errorStruct struct {
	Message string `json:"message"`
}