1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
From c865876ea7df93401349ed788422ea475dcdda9b Mon Sep 17 00:00:00 2001
From: Alyssa Ross <hi@alyssa.is>
Date: Wed, 11 May 2022 14:41:36 +0000
Subject: [PATCH 2/2] Don't include PII in logs
---
main.go | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/main.go b/main.go
index 6366db0..14ef64e 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,7 @@ import (
"context"
"flag"
"fmt"
+ "io"
"log"
"net/http"
"net/http/cgi"
@@ -27,7 +28,7 @@ func main() {
fmt.Fprintln(flag.CommandLine.Output(), "Usage: cgiserver [-r ROOT] /path/to/application.cgi")
}
- root := flag.String("r", "/", "CGI SCRIPT_NAME");
+ root := flag.String("r", "/", "CGI SCRIPT_NAME")
// We didn't configure any flags, so this just serves to display an error
// if someone tries to pass one. It also automatically handles -h/--help.
@@ -63,7 +64,11 @@ func main() {
handler = handlers.ProxyHeaders(handler)
// Additionally, we want to log requests.
- handler = handlers.CombinedLoggingHandler(os.Stdout, handler)
+ handler = handlers.CustomLoggingHandler(os.Stdout, handler,
+ func(w io.Writer, params handlers.LogFormatterParams) {
+ fmt.Fprintf(w, "%s %s %d %d\n", params.Request.Method,
+ params.URL.String(), params.StatusCode, params.Size)
+ })
// Catch SIGTERM so we can shutdown gracefully.
sig := make(chan os.Signal, 1)
--
2.35.1
|