Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
remove timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
hexahigh committed Apr 12, 2024
1 parent 087a782 commit 852e130
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bytes"
"context"
"crypto"
"database/sql"
"embed"
Expand Down Expand Up @@ -43,7 +42,7 @@ import (
"github.com/peterbourgon/ff"
)

const version = "4.0.0"
const version = "4.0.1"

var (
dataDir = flag.String("d", "./data", "Folder to store files")
Expand Down Expand Up @@ -228,13 +227,6 @@ func handleStore(w http.ResponseWriter, r *http.Request) {
Type string `json:"type"`
}

// Create a context with a timeout
ctx, cancel := context.WithTimeout(r.Context(), 60*time.Second)
defer cancel() // Make sure to cancel the context when the function returns

// Use the context with a timeout for the request
r = r.WithContext(ctx)

enableCors(&w)
if r.Method == "OPTIONS" {
return
Expand Down Expand Up @@ -423,17 +415,6 @@ func handleStore(w http.ResponseWriter, r *http.Request) {
}

json.NewEncoder(w).Encode(response)

// Before returning, check if the context was canceled due to a timeout
select {
case <-ctx.Done():
if ctx.Err() == context.DeadlineExceeded {
http.Error(w, "Request timed out", http.StatusRequestTimeout)
return
}
default:
// No timeout, proceed as normal
}
}

func handleGet(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 852e130

Please sign in to comment.