feat(proxy): Add reverse proxy feature
This commit is contained in:
27
app/middlewares/logger.go
Normal file
27
app/middlewares/logger.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package middlewares
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"git.secnex.io/secnex/masterlog"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
)
|
||||
|
||||
func LoggerMiddleware(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
start := time.Now()
|
||||
|
||||
ww := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
|
||||
next.ServeHTTP(ww, r)
|
||||
|
||||
masterlog.Info("HTTP Request", map[string]interface{}{
|
||||
"method": r.Method,
|
||||
"path": r.URL.Path,
|
||||
"status": ww.Status(),
|
||||
"duration": time.Since(start).String(),
|
||||
"host": r.Host,
|
||||
"ip": r.RemoteAddr,
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user