aboutsummaryrefslogtreecommitdiff
path: root/middleware
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-07 17:59:31 +0530
committerBobby <[email protected]>2026-03-07 17:59:31 +0530
commita6ec9a807df68978bf3b85314a4c54c60ecc2b7a (patch)
tree6201e8d594a3c368cce50ebc402f248814e2025f /middleware
parent57df54999e778887e66775481dab46191b46d0b6 (diff)
downloaddove-a6ec9a807df68978bf3b85314a4c54c60ecc2b7a.tar.xz
dove-a6ec9a807df68978bf3b85314a4c54c60ecc2b7a.zip
feat: implement SMTP server with authentication, port validation, and email storage
Diffstat (limited to 'middleware')
-rw-r--r--middleware/constants.go5
-rw-r--r--middleware/logging.go69
-rw-r--r--middleware/middleware.go1
3 files changed, 0 insertions, 75 deletions
diff --git a/middleware/constants.go b/middleware/constants.go
deleted file mode 100644
index dc6505b..0000000
--- a/middleware/constants.go
+++ /dev/null
@@ -1,5 +0,0 @@
-package middleware
-
-const (
- LOG_PREFIX = "HTTP"
-)
diff --git a/middleware/logging.go b/middleware/logging.go
deleted file mode 100644
index a8c3bd6..0000000
--- a/middleware/logging.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package middleware
-
-import (
- "fmt"
- "strconv"
- "strings"
- "time"
-
- "dove/utils/logger"
-
- "github.com/gofiber/fiber/v2"
-)
-
-func httpLogger(context *fiber.Ctx) error {
- startTime := time.Now()
-
- responseError := context.Next()
-
- duration := time.Since(startTime)
- statusCode := context.Response().StatusCode()
- method := context.Method()
- path := context.Path()
- ipAddress := context.IP()
-
- paddedMethod := method
- if len(method) < 7 {
- paddedMethod = method + strings.Repeat(" ", 7-len(method))
- }
-
- message := fmt.Sprintf(
- "%s %-3d %-15s %-10s %s",
- paddedMethod, statusCode, "IP: "+ipAddress, "TTR: "+formatDuration(duration), "Path: "+path,
- )
-
- logByStatus(statusCode, LOG_PREFIX, message)
-
- return responseError
-}
-
-func logByStatus(statusCode int, prefix string, message string) {
- switch {
- case statusCode >= fiber.StatusInternalServerError:
- logger.Errorf(prefix, "%s", message)
- case statusCode >= fiber.StatusBadRequest:
- logger.Warnf(prefix, "%s", message)
- case statusCode >= fiber.StatusMultipleChoices:
- logger.Infof(prefix, "%s", message)
- case statusCode >= fiber.StatusOK:
- logger.Successf(prefix, "%s", message)
- default:
- logger.Infof(prefix, "%s", message)
- }
-}
-
-func formatDuration(duration time.Duration) string {
- if duration < time.Microsecond {
- return strconv.FormatInt(duration.Nanoseconds(), 10) + "ns"
- }
-
- if duration < time.Millisecond {
- return strconv.FormatInt(duration.Nanoseconds()/1_000, 10) + "µs"
- }
-
- if duration < time.Second {
- return strconv.FormatFloat(float64(duration.Nanoseconds())/float64(time.Millisecond), 'f', 3, 64) + "ms"
- }
-
- return strconv.FormatFloat(float64(duration.Nanoseconds())/float64(time.Second), 'f', 3, 64) + "s"
-}
diff --git a/middleware/middleware.go b/middleware/middleware.go
index 1a4f1ed..1e73145 100644
--- a/middleware/middleware.go
+++ b/middleware/middleware.go
@@ -3,7 +3,6 @@ package middleware
import "github.com/gofiber/fiber/v2"
func Initialize(application *fiber.App) {
- application.Use(httpLogger)
application.Use(requestBuilder)
application.Use(globals)
}