Fix for deploy

This commit is contained in:
bel
2020-09-15 05:36:02 -06:00
parent a5bbf85da9
commit 6dcd11b7e9
4 changed files with 13 additions and 16 deletions

View File

@@ -3,7 +3,6 @@ package main
import (
"fmt"
"local/args"
"local/gziphttp"
"log"
"net/http"
@@ -21,13 +20,11 @@ func main() {
panic(err)
}
log.Printf("listening on %v to serve %s at %d rps", as.GetInt("port"), as.GetString("root"), as.GetInt("rps"))
s := http.FileServer(http.Dir(as.GetString("root")))
limiter := rate.NewLimiter(rate.Limit(as.GetInt("rps")), as.GetInt("rps"))
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", as.GetInt("port")), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if gziphttp.Can(r) {
gz := gziphttp.New(w)
w = gz
}
if err := limiter.Wait(r.Context()); err != nil {
log.Println("rate limited:", err)
return