Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
Remove unused/placeholder log handler
Matthew Holt committed
Oct 10, 2019 at 15:35 UTC
411152016e15fcc5363df9ff4bc3bdb19675b5d8
1 file changed
-68
modules/caddyhttp/caddylog/log.go
deleted
-68
@@ -1,68 +0,0 @@
1
-// Copyright 2015 Matthew Holt and The Caddy Authors
2
-//
3
-// Licensed under the Apache License, Version 2.0 (the "License");
4
-// you may not use this file except in compliance with the License.
5
-// You may obtain a copy of the License at
6
-//
7
-// http://www.apache.org/licenses/LICENSE-2.0
8
-//
9
-// Unless required by applicable law or agreed to in writing, software
10
-// distributed under the License is distributed on an "AS IS" BASIS,
11
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
-// See the License for the specific language governing permissions and
13
-// limitations under the License.
14
-
15
-package caddylog
16
-
17
-import (
18
- "log"
19
- "net/http"
20
- "time"
21
-
22
- "github.com/caddyserver/caddy/v2"
23
- "github.com/caddyserver/caddy/v2/modules/caddyhttp"
24
-)
25
-
26
-func init() {
27
- caddy.RegisterModule(Log{})
28
-}
29
-
30
-// Log implements a simple logging middleware.
31
-type Log struct {
32
- Filename string
33
- counter int
34
-}
35
-
36
-// CaddyModule returns the Caddy module information.
37
-func (Log) CaddyModule() caddy.ModuleInfo {
38
- return caddy.ModuleInfo{
39
- Name: "http.handlers.log",
40
- New: func() caddy.Module { return new(Log) },
41
- }
42
-}
43
-
44
-func (l *Log) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error {
45
- start := time.Now()
46
-
47
- // TODO: An example of returning errors
48
- // return caddyhttp.Error(http.StatusBadRequest, fmt.Errorf("this is a basic error"))
49
- // return caddyhttp.Error(http.StatusBadGateway, caddyhttp.HandlerError{
50
- // Err: fmt.Errorf("this is a detailed error"),
51
- // Message: "We had trouble doing the thing.",
52
- // Recommendations: []string{
53
- // "Try reconnecting the gizbop.",
54
- // "Turn off the Internet.",
55
- // },
56
- // })
57
-
58
- if err := next.ServeHTTP(w, r); err != nil {
59
- return err
60
- }
61
-
62
- log.Println("latency:", time.Now().Sub(start), l.counter)
63
-
64
- return nil
65
-}
66
-
67
-// Interface guard
68
-var _ caddyhttp.MiddlewareHandler = (*Log)(nil)