summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/api/handlers.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/internal/api/handlers.go b/internal/api/handlers.go
index 6fb6361..45354aa 100644
--- a/internal/api/handlers.go
+++ b/internal/api/handlers.go
@@ -17,7 +17,7 @@ func init() {
fs = http.FileServer(http.Dir("static"))
}
-const log_length = 100
+const LogLength = 100
type accessLog struct {
ClientAddr string `json:"clientAddr"`
@@ -26,7 +26,7 @@ type accessLog struct {
HttpMethod string `json:"httpMethod"`
}
-func CreateFilesHandler(logs *[log_length]string, n *int, logChan chan string) http.HandlerFunc {
+func CreateFilesHandler(logs *[LogLength]string, n *int, logChan chan string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
jsonData, _ := json.Marshal(accessLog{
ClientAddr: redactIP(r.RemoteAddr),
@@ -40,7 +40,7 @@ func CreateFilesHandler(logs *[log_length]string, n *int, logChan chan string) h
}
}
-func CreateGetLogs(logs *[log_length]string) http.HandlerFunc {
+func CreateGetLogs(logs *[LogLength]string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
for _, s := range logs {
fmt.Fprintln(w, s)
@@ -48,7 +48,7 @@ func CreateGetLogs(logs *[log_length]string) http.HandlerFunc {
}
}
-func CreateLoginHandler(logs *[log_length]string, n *int, logChan chan string) http.HandlerFunc {
+func CreateLoginHandler(logs *[LogLength]string, n *int, logChan chan string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil {
@@ -89,17 +89,17 @@ func redactIP(input string) string {
})
}
-func addRotLog(logs *[log_length]string, last *int, parser chan string, value string) {
+func addRotLog(logs *[LogLength]string, last *int, parser chan string, value string) {
if strings.Contains(value, "\n") {
for _, v := range strings.Split(value, "\n") {
addRotLog(logs, last, parser, v)
}
} else {
- if *last == log_length {
- for i := 0; i < log_length-1; i++ {
+ if *last == LogLength {
+ for i := 0; i < LogLength-1; i++ {
logs[i] = logs[i+1]
}
- logs[log_length-1] = value
+ logs[LogLength-1] = value
parser <- value
} else {
logs[*last] = value