Skip to content
Snippets Groups Projects
Commit 726e59c5 authored by Cédric OLIVIER's avatar Cédric OLIVIER
Browse files

Merge branch 'fix-lint-issue' into 'master'

fix: linter issue related to G112: Potential Slowloris Attack

See merge request to-be-continuous/tools/tracking!30
parents 8b96a052 38126d6b
No related branches found
No related tags found
No related merge requests found
...@@ -23,12 +23,15 @@ import ( ...@@ -23,12 +23,15 @@ import (
"log" "log"
"net/http" "net/http"
"strings" "strings"
"time"
) )
type healthResponse struct { type healthResponse struct {
Status string `json:"status"` Status string `json:"status"`
} }
const readHeaderTimeout = 2 * time.Second
func serverHandler(writer http.ResponseWriter, request *http.Request) { func serverHandler(writer http.ResponseWriter, request *http.Request) {
if strings.ToUpper(request.Method) != "GET" { if strings.ToUpper(request.Method) != "GET" {
http.Error(writer, "Method not allowed", http.StatusMethodNotAllowed) http.Error(writer, "Method not allowed", http.StatusMethodNotAllowed)
...@@ -54,6 +57,10 @@ func health(writer http.ResponseWriter, request *http.Request) { ...@@ -54,6 +57,10 @@ func health(writer http.ResponseWriter, request *http.Request) {
func HealthService(port int) (error, *http.Server) { func HealthService(port int) (error, *http.Server) {
log.Printf("Starting application on port %d\n", port) log.Printf("Starting application on port %d\n", port)
server := &http.Server{Addr: fmt.Sprintf(":%d", port), Handler: http.HandlerFunc(serverHandler)} server := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: http.HandlerFunc(serverHandler),
ReadHeaderTimeout: readHeaderTimeout,
}
return server.ListenAndServe(), server return server.ListenAndServe(), server
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment