Fix for deploy
This commit is contained in:
7
main.go
7
main.go
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user