first commit
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
# ProxyEngine
|
||||
|
||||
**Özet:** HTTP isteklerini upstream backend'e ileten merkezi proxy motoru (`internal/proxy/proxy.go:24`). Tüm header'ları korur, hassas header'ları log'da maskeler, hop-by-hop header'ları otomatik atlar.
|
||||
|
||||
**Kütüphaneler:** Go `net/http`, `context`, `io`
|
||||
|
||||
**Bağlantılar:** [[OpenAIHandler]], [[AnthropicHandler]], [[Index]]
|
||||
|
||||
## Struct
|
||||
|
||||
```go
|
||||
type ForwardResult struct {
|
||||
StatusCode int
|
||||
Body []byte
|
||||
Headers http.Header
|
||||
}
|
||||
```
|
||||
|
||||
## Fonksiyonlar
|
||||
|
||||
### `Forward(ctx, method, targetURL, headers, body, timeoutSec) *ForwardResult`
|
||||
- HTTP isteğini hedef URL'ye iletir
|
||||
- Context üzerinden timeout yönetimi (`time.Duration(timeoutSec) * time.Second`)
|
||||
- Hop-by-hop header'ları atlar: `Connection`, `TE`, `Trailers`, `Transfer-Encoding`, `Upgrade`
|
||||
- Body'yi log için okur, sonra tekrar sarar
|
||||
- `ForwardResult{StatusCode, Body, Headers}` döndürür
|
||||
|
||||
### `MaskSensitiveHeaders(headers) http.Header`
|
||||
- Header'ları clone'lar
|
||||
- `Authorization` → `Bearer [REDACTED]`
|
||||
- `X-Api-Key` → `[REDACTED]`
|
||||
- Sadece loglama amaçlı kullanılır; upstream'e orijinal header gider
|
||||
|
||||
### `truncateForLog(s, maxLen) string`
|
||||
- Uzun string'leri `maxLen` (2000) karakterde kırpar, `...[TRUNCATED]` ekler
|
||||
|
||||
## Güvenlik
|
||||
|
||||
- Hassas header'lar upstream'e **olduğu gibi** iletilir ama **log'da maskelenir**
|
||||
- Hop-by-hop header'lar otomatik atlanır (proxy zincirini bozmamak için)
|
||||
- Sensitive header masking sadece log çıktısı içindir
|
||||
Reference in New Issue
Block a user