summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/caddylog/log.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/caddyhttp/caddylog/log.go')
-rw-r--r--modules/caddyhttp/caddylog/log.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/modules/caddyhttp/caddylog/log.go b/modules/caddyhttp/caddylog/log.go
index f7bc9fd..dc940b3 100644
--- a/modules/caddyhttp/caddylog/log.go
+++ b/modules/caddyhttp/caddylog/log.go
@@ -13,6 +13,7 @@ func init() {
caddy2.RegisterModule(caddy2.Module{
Name: "http.middleware.log",
New: func() (interface{}, error) { return new(Log), nil },
+ // TODO: Examples of OnLoad and OnUnload.
OnLoad: func(instances []interface{}, priorState interface{}) (interface{}, error) {
var counter int
if priorState != nil {
@@ -42,6 +43,17 @@ type Log struct {
func (l *Log) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
start := time.Now()
+ // TODO: An example of returning errors
+ // return caddyhttp.Error(http.StatusBadRequest, fmt.Errorf("this is a basic error"))
+ // return caddyhttp.Error(http.StatusBadGateway, caddyhttp.HandlerError{
+ // Err: fmt.Errorf("this is a detailed error"),
+ // Message: "We had trouble doing the thing.",
+ // Recommendations: []string{
+ // "Try reconnecting the gizbop.",
+ // "Turn off the Internet.",
+ // },
+ // })
+
if err := next.ServeHTTP(w, r); err != nil {
return err
}