Skip to content

Commit

Permalink
Merge pull request #45 from kdauzickas/master
Browse files Browse the repository at this point in the history
Add flag to change healthcheck url
  • Loading branch information
jacobbednarz authored Sep 22, 2020
2 parents 65aa073 + 25c4fc1 commit 5e5a12f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ $ CGO_ENABLED=0 go build csp_collector.go
|debug |Runs in debug mode producing more verbose output|
|port |Port to run on, default 8080|
|filter-file|Reads the blocked URI filter list from the specified file. Note one filter per line|
|health-check-path|Sets path for health checkers to use, default \/_healthcheck|


See the sample.filterlist.txt file as an example of the filter list in a file
Expand Down
6 changes: 5 additions & 1 deletion csp_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ var (
// Flag for toggling output format.
outputFormat string

// Flag for health check url.
healthCheckPath = "/_healthcheck"

// Shared defaults for the logger output. This ensures that we are
// using the same keys for the `FieldKey` values across both formatters.
logFieldMapDefaults = log.FieldMap{
Expand Down Expand Up @@ -114,6 +117,7 @@ func main() {
flag.StringVar(&outputFormat, "output-format", "text", "Define how the violation reports are formatted for output.\nDefaults to 'text'. Valid options are 'text' or 'json'")
flag.StringVar(&blockedURIfile, "filter-file", "", "Blocked URI Filter file")
flag.IntVar(&listenPort, "port", 8080, "Port to listen on")
flag.StringVar(&healthCheckPath, "health-check-path", healthCheckPath, "Health checker path")

flag.Parse()

Expand Down Expand Up @@ -162,7 +166,7 @@ func main() {
}

func handleViolationReport(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" && r.URL.Path == "/_healthcheck" {
if r.Method == "GET" && r.URL.Path == healthCheckPath {
w.WriteHeader(http.StatusOK)
return
}
Expand Down

0 comments on commit 5e5a12f

Please sign in to comment.