feat: better caching headers for images

This commit is contained in:
2026-03-09 13:35:23 +01:00
parent a27b4a66e6
commit 2b07701762
11 changed files with 83 additions and 43 deletions
+9 -3
View File
@@ -27,10 +27,16 @@ func Start(ctx context.Context, cfg config.Cfg) (err error) {
cfg: cfg,
}
hander, err := s.allRoutes()
if err != nil {
err = fmt.Errorf("could not setup routes: %w", err)
return
}
// Declare Server config
srv := &http.Server{
Addr: fmt.Sprintf(":%d", s.port),
Handler: s.RegisterRoutes(),
Handler: hander,
IdleTimeout: time.Minute,
ReadTimeout: 10 * time.Second,
WriteTimeout: 30 * time.Second,
@@ -45,7 +51,7 @@ func Start(ctx context.Context, cfg config.Cfg) (err error) {
// Shutdown server when ctx done
if err = srv.Shutdown(context.Background()); err != nil {
// Error from closing listeners, or context timeout:
err = fmt.Errorf("error whilse shutting down server: %w", err)
err = fmt.Errorf("error while shutting down server: %w", err)
}
close(idleConnsClosed)
@@ -53,7 +59,7 @@ func Start(ctx context.Context, cfg config.Cfg) (err error) {
slog.Info("starting server", "address", srv.Addr)
if err := srv.ListenAndServe(); err != http.ErrServerClosed {
return fmt.Errorf("error while server ListenAndServe: %w", err)
return fmt.Errorf("error while serving: %w", err)
}
<-idleConnsClosed