Update server

This commit is contained in:
Milan Nikolic
2025-06-15 08:34:19 +02:00
parent bf647116a3
commit d84884f26b
2 changed files with 7 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ func (j *JPEG) ServeHTTP(w http.ResponseWriter, r *http.Request) {
img, err := j.reader.Read()
if err != nil {
log.Printf("jpeg: read: %v", err)
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
return
}
@@ -40,6 +41,7 @@ func (j *JPEG) ServeHTTP(w http.ResponseWriter, r *http.Request) {
err = image.NewEncoder(w, j.quality).Encode(img)
if err != nil {
log.Printf("jpeg: encode: %v", err)
http.Error(w, "500 Internal Server Error", http.StatusInternalServerError)
return
}

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"net"
"net/http"
"time"
"github.com/abbot/go-http-auth"
@@ -63,7 +64,10 @@ func (s *Server) ListenAndServe() error {
http.Handle("/", newAuthHandler(handlers.NewIndex(), basic))
srv := &http.Server{}
srv := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 5 * time.Second,
}
listener, err := net.Listen("tcp", s.Bind)
if err != nil {