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

Commit

Permalink
backend staticcheck fixes and add Server header
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann committed Mar 29, 2023
1 parent 0a92fd0 commit f06dc97
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 32 deletions.
4 changes: 2 additions & 2 deletions backend/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,11 @@ func makeGatewayCARHandler(bsrv blockservice.BlockService, port int) (*http.Serv
const immutableCacheControl = "public, max-age=29030400, immutable"
// immutable! CACHE ALL THE THINGS, FOREVER! wolololol
w.Header().Set("Cache-Control", immutableCacheControl)
w.Header().Set("Server", userAgent)

// Set modtime to 'zero time' to disable Last-Modified header (superseded by Cache-Control)

io.Copy(w, carStream)
return
})

// Creates metrics handler for total response size. Matches the same metrics
Expand Down Expand Up @@ -591,11 +591,11 @@ func makeGatewayBlockHandler(bsrv blockservice.BlockService, port int) (*http.Se
const immutableCacheControl = "public, max-age=29030400, immutable"
// immutable! CACHE ALL THE THINGS, FOREVER! wolololol
w.Header().Set("Cache-Control", immutableCacheControl)
w.Header().Set("Server", userAgent)

// Set modtime to 'zero time' to disable Last-Modified header (superseded by Cache-Control)

http.ServeContent(w, r, c.String()+".bin", noModtime, bytes.NewReader(blk.RawData()))
return
})

// Creates metrics handler for total response size. Matches the same metrics
Expand Down
30 changes: 0 additions & 30 deletions backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"net/http"
"os"
"os/signal"
"strconv"
"strings"
"sync"
)

Expand Down Expand Up @@ -146,31 +144,3 @@ var rootCmd = &cobra.Command{
return nil
},
}

func getEnv(key, defaultValue string) string {
value := os.Getenv(key)
if value == "" {
return defaultValue
}
return value
}

func getEnvs(key, defaultValue string) []string {
value := os.Getenv(key)
if value == "" {
if defaultValue == "" {
return []string{}
}
value = defaultValue
}
value = strings.TrimSpace(value)
return strings.Split(value, ",")
}

func getEnvInt(key string, defaultValue int) (int, error) {
value := os.Getenv(key)
if value == "" {
return defaultValue, nil
}
return strconv.Atoi(value)
}

0 comments on commit f06dc97

Please sign in to comment.