Skip to content

Commit 0f5b85a

Browse files
committed
use explict structs for report-only values
1 parent b730cf1 commit 0f5b85a

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

main.go

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,38 @@ func main() {
9898
r := mux.NewRouter()
9999
r.HandleFunc(*healthCheckPath, handler.HealthcheckHandler).Methods("GET")
100100

101-
cspHandler := &handler.CSPViolationReportHandler{
101+
r.Handle("/csp/report-only", &handler.CSPViolationReportHandler{
102102
BlockedURIs: ignoredBlockedURIs,
103103
TruncateQueryStringFragment: *truncateQueryStringFragment,
104104

105105
LogClientIP: *logClientIP,
106106
LogTruncatedClientIP: *logTruncatedClientIP,
107107
MetadataObject: *metadataObject,
108108
Logger: logger,
109-
}
109+
ReportOnly: true,
110+
}).Methods("POST")
111+
112+
r.Handle("/csp", &handler.CSPViolationReportHandler{
113+
BlockedURIs: ignoredBlockedURIs,
114+
TruncateQueryStringFragment: *truncateQueryStringFragment,
110115

111-
reportOnlyCspHandler := cspHandler
112-
reportOnlyCspHandler.ReportOnly = true
116+
LogClientIP: *logClientIP,
117+
LogTruncatedClientIP: *logTruncatedClientIP,
118+
MetadataObject: *metadataObject,
119+
Logger: logger,
120+
ReportOnly: false,
121+
}).Methods("POST")
113122

114-
r.Handle("/csp", cspHandler).Methods("POST")
115-
r.Handle("/csp/report-only", reportOnlyCspHandler).Methods("POST")
116-
r.Handle("/", cspHandler).Methods("POST")
123+
r.Handle("/", &handler.CSPViolationReportHandler{
124+
BlockedURIs: ignoredBlockedURIs,
125+
TruncateQueryStringFragment: *truncateQueryStringFragment,
126+
127+
LogClientIP: *logClientIP,
128+
LogTruncatedClientIP: *logTruncatedClientIP,
129+
MetadataObject: *metadataObject,
130+
Logger: logger,
131+
ReportOnly: false,
132+
}).Methods("POST")
117133

118134
r.NotFoundHandler = r.NewRoute().HandlerFunc(http.NotFound).GetHandler()
119135

0 commit comments

Comments
 (0)