/
githubmirror
/
photoprism
Обзор
Документация
Войти
/
githubmirror
/
photoprism
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
internal/server/logger.go
42 строки
726 B
Michael Mayer
Security: Add http rate limiter and auto tls mode #98
11 окт 2022, 23:44
11 окт 2022, 23:44
6abbc39
Код
Авторство
О чём код?
package server import ( "time" "github.com/gin-gonic/gin" "github.com/photoprism/photoprism/pkg/clean" ) // Logger instances a Logger middleware for Gin. func Logger() gin.HandlerFunc { return func(c *gin.Context) { // Start timer start := time.Now() path := c.Request.URL.Path raw := c.Request.URL.RawQuery // Process request c.Next() // Stop timer end := time.Now() latency := end.Sub(start) // clientIp := c.ClientIP() method := c.Request.Method statusCode := c.Writer.Status() if raw != "" { path = path + "?" + raw } // Use debug level to keep production logs clean. log.Debugf("server: %s %s (%3d) [%v]", method, clean.Log(path), statusCode, latency, ) } }