summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRobby Zambito <contact@robbyzambito.me>2025-08-06 15:59:19 -0400
committerRobby Zambito <contact@robbyzambito.me>2025-08-06 15:59:35 -0400
commit8293c81319004aa76eb2991894a70b0496ff5bc0 (patch)
tree7ec47102e8e04fafcf86dc66b0e0c65dfdeac726 /main.go
parent34ba44274bcb67f4598ee2e18feb5b68a3984e48 (diff)
Wrap auth requests in authRequest object
Remove debug prints
Diffstat (limited to 'main.go')
-rw-r--r--main.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.go b/main.go
index 56e3b51..aef29cb 100644
--- a/main.go
+++ b/main.go
@@ -12,6 +12,9 @@ import (
"time"
)
+// Example:
+// curl 'http://localhost:8080/v1/auth/login' -X POST -H 'Content-Type: application/json' --data-raw $'{}}\n{"king": 5'
+
const log_length = 100
type accessLog struct {
@@ -61,15 +64,14 @@ func main() {
// Attempt to parse JSON (optional, if you still want to try)
var data map[string]any
if json.Unmarshal(body, &data) != nil {
- addRotLog(&logs, &n, string(body)) // Logs unmodified string
+ addRotLog(&logs, &n, fmt.Sprintf(`{"authRequest": %s}`, string(body))) // Logs unmodified string
http.Error(w, "Forbidden", http.StatusForbidden)
return
}
if email, ok := data["email"].(string); ok {
if rememberMe, ok := data["rememberMe"].(bool); ok {
- fmt.Println("Successfully unmarshalled json")
- addRotLog(&logs, &n, fmt.Sprintf(`{"email": "%s", "password": "XXXXXXXX", "loginTime": "%s", "success": false, "rememberMe": %t}`, email, time.Now().UTC(), rememberMe))
+ addRotLog(&logs, &n, fmt.Sprintf(`{"authRequest": {"email": "%s", "password": "XXXXXXXX", "loginTime": "%s", "success": false, "rememberMe": %t}}`, email, time.Now().UTC(), rememberMe))
}
}
http.Error(w, "Forbidden", http.StatusForbidden)
@@ -93,7 +95,6 @@ func createGetLogs(logs *[log_length]string) func(http.ResponseWriter, *http.Req
}
func addRotLog(logs *[log_length]string, last *int, value string) {
- fmt.Printf("%d %t %v\n", *last, strings.Contains(value, "\n"), value)
if strings.Contains(value, "\n") {
for _, v := range strings.Split(value, "\n") {
addRotLog(logs, last, v)