first commit

This commit is contained in:
Beyhan Ogur
2026-05-11 15:08:50 +03:00
commit a408821410
47 changed files with 4670 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
package models
import (
"time"
"gorm.io/gorm"
)
const maxBodyLength = 2000
// RequestLog stores a minimal record of every proxied request.
// Sensitive headers (e.g. Authorization) are NEVER stored verbatim.
type RequestLog struct {
ID uint `gorm:"primarykey" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
Endpoint string `gorm:"size:512" json:"endpoint"`
Method string `gorm:"size:16" json:"method"`
ClientIP string `gorm:"size:64" json:"client_ip"`
RequestBody string `gorm:"type:text" json:"request_body"`
ResponseStatus int `json:"response_status"`
LatencyMs int64 `json:"latency_ms"`
}
// TruncateBody returns at most maxBodyLength characters from body.
func TruncateBody(body string) string {
if len(body) <= maxBodyLength {
return body
}
return body[:maxBodyLength] + "…[truncated]"
}