tsweb: add a Handler type.

Handler is like http.Handler, but returns errors. ErrHandler
converts back to an http.Handler, with added error handling
and logging.

Signed-off-by: David Anderson <dave@natulte.net>
This commit is contained in:
David Anderson
2020-03-17 20:35:59 -07:00
committed by Dave Anderson
parent f8d67bb591
commit 98eceae55e
2 changed files with 63 additions and 4 deletions
+3 -1
View File
@@ -43,7 +43,9 @@ func (m Msg) String() string {
return strings.TrimRight(buf.String(), "\n")
}
// HTTPError is an error with embedded HTTP response information.
// HTTPError is an error with embedded HTTP response information. When
// received by an ErrHandler, the Code and Msg are sent to the client,
// while Err is logged on the server.
type HTTPError struct {
Code int
Msg string // sent to the end-user