Enhance environment variable documentation and configuration
Format / gofmt (push) Successful in 1m17s
CI / Build (push) Successful in 1m31s
CI / Go Tests (push) Successful in 1m36s

- Updated `.env.example` to include new environment variables for server access logging and security settings, ensuring comprehensive configuration options.
- Revised `docker-entrypoint.sh` to clarify the source of supported environment variables.
- Improved `README.md` to reflect the latest environment variable changes and maintain synchronization with the canonical list in `internal/config/config.go`.
- Added tests to ensure documentation consistency across `.env.example` and `README.md`, preventing future discrepancies.
This commit is contained in:
2026-07-15 16:24:55 -05:00
parent ad4355df17
commit 90eb56465b
11 changed files with 268 additions and 15 deletions
@@ -373,3 +373,49 @@ func min(a, b int) int {
}
return b
}
// Scratches larger than limits.raw_cache_max_size must stream from storage
// (no full in-memory buffer) so multi-GiB downloads stay viable.
func TestRawStreamsWhenLargerThanCache(t *testing.T) {
t.Parallel()
payload := bytes.Repeat([]byte("Z"), 8*1024) // 8 KiB body
handler := newTestHandler(t, testServerOptions{
maxUploadBytes: int64(len(payload) * 2),
defaultTTL: time.Hour,
rateLimitEnable: false,
rawCacheBytes: 1024, // smaller than payload => stream path
})
createReq := httptest.NewRequest(http.MethodPost, "/api/scratch", bytes.NewReader(payload))
createReq.Header.Set("Content-Type", "application/octet-stream")
createReq.RemoteAddr = "127.0.0.1:7100"
createRec := httptest.NewRecorder()
handler.ServeHTTP(createRec, createReq)
if createRec.Code != http.StatusCreated {
t.Fatalf("create status = %d, want 201 body=%q", createRec.Code, createRec.Body.String())
}
var created map[string]any
if err := json.Unmarshal(createRec.Body.Bytes(), &created); err != nil {
t.Fatalf("decode create payload: %v", err)
}
id, _ := created["id"].(string)
if id == "" {
t.Fatal("create payload missing id")
}
rawReq := httptest.NewRequest(http.MethodGet, "/api/raw/"+id, nil)
rawReq.RemoteAddr = "127.0.0.1:7101"
rawRec := httptest.NewRecorder()
handler.ServeHTTP(rawRec, rawReq)
if rawRec.Code != http.StatusOK {
t.Fatalf("raw status = %d, want 200", rawRec.Code)
}
if got := rawRec.Header().Get("Accept-Ranges"); got != "none" {
t.Fatalf("Accept-Ranges = %q, want none (stream path)", got)
}
if got := rawRec.Body.Bytes(); !bytes.Equal(got, payload) {
t.Fatalf("raw body len=%d, want %d (content mismatch or truncated)", len(got), len(payload))
}
}