Remove runtime nil checks for always-initialized components

Since signing_key is now required at config load time, sessMgr, encGen,
and signer are always initialized. Remove unnecessary nil checks that
were runtime failure paths that can no longer be reached.

- handlers.go: Remove conditional init, always create sessMgr/encGen
- auth.go: Remove nil checks for sessMgr
- imageenc.go: Remove nil check for encGen
- service.go: Require signing_key in NewService, remove signer nil checks
- Update tests to provide signing_key
This commit is contained in:
2026-01-08 15:58:44 -08:00
parent 02dedd433b
commit 3849128c45
6 changed files with 27 additions and 51 deletions

View File

@@ -55,9 +55,10 @@ func setupTestHandler(t *testing.T) *testFixtures {
}
svc, err := imgcache.NewService(&imgcache.ServiceConfig{
Cache: cache,
Fetcher: newMockFetcher(mockFS),
Whitelist: []string{goodHost},
Cache: cache,
Fetcher: newMockFetcher(mockFS),
SigningKey: "test-signing-key-must-be-32-chars",
Whitelist: []string{goodHost},
})
if err != nil {
t.Fatalf("failed to create service: %v", err)