This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
bactdb/handlers/error.go
Matthew Dillon e756b13099 Refactor handlers package
Fixes #19.
2015-10-13 11:06:02 -07:00

17 lines
344 B
Go

package handlers
import (
"fmt"
"net/http"
"github.com/thermokarst/bactdb/types"
)
type errorHandler func(http.ResponseWriter, *http.Request) *types.AppError
func (fn errorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if err := fn(w, r); err != nil {
w.WriteHeader(err.Status)
fmt.Fprintln(w, err.Error.Error())
}
}